@wrelik/errors 0.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,56 +1,28 @@
1
1
 
2
- > @wrelik/errors@0.2.0 build /home/runner/work/wrelik-kit/wrelik-kit/packages/errors
3
- > tsup src/node.ts src/browser.ts src/react-native.ts --format cjs,esm --dts --clean
2
+ > @wrelik/errors@2.0.0 build /home/runner/work/wrelik-kit/wrelik-kit/packages/errors
3
+ > tsup src/server/index.ts src/client/index.ts src/shared/index.ts --format cjs,esm --dts --clean
4
4
 
5
- CLI Building entry: src/browser.ts, src/node.ts, src/react-native.ts
5
+ CLI Building entry: src/client/index.ts, src/server/index.ts, src/shared/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.1
8
8
  CLI Target: es2022
9
9
  CLI Cleaning output folder
10
10
  CJS Build start
11
11
  ESM Build start
12
- [warn] ▲ [WARNING] Duplicate key "skipLibCheck" in object literal [duplicate-object-key]
13
-
14
- tsconfig.json:5:4:
15
-  5 "skipLibCheck": true
16
- ~~~~~~~~~~~~~~
17
-
18
- The original key "skipLibCheck" is here:
19
-
20
- tsconfig.json:4:22:
21
-  4 │ "outDir": "dist", "skipLibCheck": true,
22
- ╵ ~~~~~~~~~~~~~~
23
-
24
-
25
- [warn] ▲ [WARNING] Duplicate key "skipLibCheck" in object literal [duplicate-object-key]
26
-
27
- tsconfig.json:5:4:
28
-  5 │ "skipLibCheck": true
29
- ╵ ~~~~~~~~~~~~~~
30
-
31
- The original key "skipLibCheck" is here:
32
-
33
- tsconfig.json:4:22:
34
-  4 │ "outDir": "dist", "skipLibCheck": true,
35
- ╵ ~~~~~~~~~~~~~~
36
-
37
-
38
- CJS dist/node.js 3.84 KB
39
- CJS dist/browser.js 3.86 KB
40
- CJS dist/react-native.js 3.90 KB
41
- CJS ⚡️ Build success in 70ms
42
- ESM dist/browser.mjs 895.00 B
43
- ESM dist/node.mjs 889.00 B
44
- ESM dist/react-native.mjs 918.00 B
45
- ESM dist/chunk-EARDCOC4.mjs 1.34 KB
46
- ESM ⚡️ Build success in 69ms
12
+ ESM dist/server/index.mjs 693.00 B
13
+ ESM dist/shared/index.mjs 287.00 B
14
+ ESM dist/client/index.mjs 87.00 B
15
+ ESM dist/chunk-SK2GZ7XR.mjs 1.68 KB
16
+ ESM ⚡️ Build success in 66ms
17
+ CJS dist/client/index.js 1.96 KB
18
+ CJS dist/server/index.js 3.20 KB
19
+ CJS dist/shared/index.js 2.91 KB
20
+ CJS ⚡️ Build success in 66ms
47
21
  DTS Build start
48
- DTS ⚡️ Build success in 3543ms
49
- DTS dist/browser.d.ts 432.00 B
50
- DTS dist/node.d.ts 432.00 B
51
- DTS dist/react-native.d.ts 475.00 B
52
- DTS dist/shared-DXFP3J32.d.ts 851.00 B
53
- DTS dist/browser.d.mts 433.00 B
54
- DTS dist/node.d.mts 433.00 B
55
- DTS dist/react-native.d.mts 476.00 B
56
- DTS dist/shared-DXFP3J32.d.mts 851.00 B
22
+ DTS ⚡️ Build success in 9018ms
23
+ DTS dist/server/index.d.ts 370.00 B
24
+ DTS dist/shared/index.d.ts 1.08 KB
25
+ DTS dist/client/index.d.ts 84.00 B
26
+ DTS dist/server/index.d.mts 371.00 B
27
+ DTS dist/shared/index.d.mts 1.08 KB
28
+ DTS dist/client/index.d.mts 85.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @wrelik/errors
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 818ed58: Refactor runtime packages to strict subpath exports (`/server`, `/client`, `/shared`) with side-effect free entrypoints and hard CI/runtime boundary enforcement.
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 2b9cbf7: Fix auth role checks to reject malformed runtime role payloads and remove a duplicate TypeScript compiler option in errors to eliminate build warnings.
14
+
15
+ ## Unreleased
16
+
17
+ ### Patch Changes
18
+
19
+ - Remove duplicate `skipLibCheck` key from TypeScript config to eliminate build warnings.
20
+
3
21
  ## 0.2.0
4
22
 
5
23
  ### Minor Changes
@@ -1,8 +1,7 @@
1
- // src/shared.ts
1
+ // src/shared/types.ts
2
2
  var AppError = class extends Error {
3
3
  code;
4
4
  statusCode;
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
5
  context;
7
6
  constructor(message, code, statusCode = 500, context) {
8
7
  super(message);
@@ -13,34 +12,58 @@ var AppError = class extends Error {
13
12
  }
14
13
  };
15
14
  var AuthRequiredError = class extends AppError {
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
15
  constructor(message = "Authentication required", context) {
18
16
  super(message, "AUTH_REQUIRED", 401, context);
19
17
  }
20
18
  };
21
19
  var TenantRequiredError = class extends AppError {
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
20
  constructor(message = "Tenant context required", context) {
24
21
  super(message, "TENANT_REQUIRED", 400, context);
25
22
  }
26
23
  };
27
24
  var PermissionDeniedError = class extends AppError {
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
25
  constructor(message = "Permission denied", context) {
30
26
  super(message, "PERMISSION_DENIED", 403, context);
31
27
  }
32
28
  };
33
29
  var ValidationError = class extends AppError {
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
30
  constructor(message, context) {
36
31
  super(message, "VALIDATION_ERROR", 400, context);
37
32
  }
38
33
  };
34
+ function normalizeError(err, context) {
35
+ if (err instanceof AppError) {
36
+ return {
37
+ name: err.name,
38
+ message: err.message,
39
+ code: err.code,
40
+ statusCode: err.statusCode,
41
+ context: context ? { ...err.context, ...context } : err.context
42
+ };
43
+ }
44
+ if (err instanceof Error) {
45
+ return {
46
+ name: err.name,
47
+ message: err.message,
48
+ code: "INTERNAL_ERROR",
49
+ statusCode: 500,
50
+ context
51
+ };
52
+ }
53
+ return {
54
+ name: "Error",
55
+ message: "Unknown error",
56
+ code: "INTERNAL_ERROR",
57
+ statusCode: 500,
58
+ context: context ? { ...context, originalError: err } : { originalError: err }
59
+ };
60
+ }
39
61
 
40
62
  export {
41
63
  AppError,
42
64
  AuthRequiredError,
43
65
  TenantRequiredError,
44
66
  PermissionDeniedError,
45
- ValidationError
67
+ ValidationError,
68
+ normalizeError
46
69
  };
@@ -0,0 +1 @@
1
+ export { ErrorContext, NormalizedError, normalizeError } from '../shared/index.mjs';
@@ -0,0 +1 @@
1
+ export { ErrorContext, NormalizedError, normalizeError } from '../shared/index.js';
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/client/index.ts
21
+ var client_exports = {};
22
+ __export(client_exports, {
23
+ normalizeError: () => normalizeError
24
+ });
25
+ module.exports = __toCommonJS(client_exports);
26
+
27
+ // src/shared/types.ts
28
+ var AppError = class extends Error {
29
+ code;
30
+ statusCode;
31
+ context;
32
+ constructor(message, code, statusCode = 500, context) {
33
+ super(message);
34
+ this.name = "AppError";
35
+ this.code = code;
36
+ this.statusCode = statusCode;
37
+ this.context = context;
38
+ }
39
+ };
40
+ function normalizeError(err, context) {
41
+ if (err instanceof AppError) {
42
+ return {
43
+ name: err.name,
44
+ message: err.message,
45
+ code: err.code,
46
+ statusCode: err.statusCode,
47
+ context: context ? { ...err.context, ...context } : err.context
48
+ };
49
+ }
50
+ if (err instanceof Error) {
51
+ return {
52
+ name: err.name,
53
+ message: err.message,
54
+ code: "INTERNAL_ERROR",
55
+ statusCode: 500,
56
+ context
57
+ };
58
+ }
59
+ return {
60
+ name: "Error",
61
+ message: "Unknown error",
62
+ code: "INTERNAL_ERROR",
63
+ statusCode: 500,
64
+ context: context ? { ...context, originalError: err } : { originalError: err }
65
+ };
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ normalizeError
70
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ normalizeError
3
+ } from "../chunk-SK2GZ7XR.mjs";
4
+ export {
5
+ normalizeError
6
+ };
@@ -0,0 +1,13 @@
1
+ import { ErrorContext } from '../shared/index.mjs';
2
+
3
+ declare function initErrors(config: {
4
+ dsn: string;
5
+ tracesSampleRate?: number;
6
+ }): void;
7
+ declare function setUserContext(user: {
8
+ id: string;
9
+ email?: string;
10
+ } | null): void;
11
+ declare function captureError(err: unknown, context?: ErrorContext): void;
12
+
13
+ export { captureError, initErrors, setUserContext };
@@ -0,0 +1,13 @@
1
+ import { ErrorContext } from '../shared/index.js';
2
+
3
+ declare function initErrors(config: {
4
+ dsn: string;
5
+ tracesSampleRate?: number;
6
+ }): void;
7
+ declare function setUserContext(user: {
8
+ id: string;
9
+ email?: string;
10
+ } | null): void;
11
+ declare function captureError(err: unknown, context?: ErrorContext): void;
12
+
13
+ export { captureError, initErrors, setUserContext };
@@ -27,26 +27,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/react-native.ts
31
- var react_native_exports = {};
32
- __export(react_native_exports, {
33
- AppError: () => AppError,
34
- AuthRequiredError: () => AuthRequiredError,
35
- PermissionDeniedError: () => PermissionDeniedError,
36
- TenantRequiredError: () => TenantRequiredError,
37
- ValidationError: () => ValidationError,
30
+ // src/server/index.ts
31
+ var server_exports = {};
32
+ __export(server_exports, {
38
33
  captureError: () => captureError,
39
34
  initErrors: () => initErrors,
40
35
  setUserContext: () => setUserContext
41
36
  });
42
- module.exports = __toCommonJS(react_native_exports);
43
- var Sentry = __toESM(require("@sentry/react-native"));
37
+ module.exports = __toCommonJS(server_exports);
38
+ var Sentry = __toESM(require("@sentry/node"));
44
39
 
45
- // src/shared.ts
40
+ // src/shared/types.ts
46
41
  var AppError = class extends Error {
47
42
  code;
48
43
  statusCode;
49
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
44
  context;
51
45
  constructor(message, code, statusCode = 500, context) {
52
46
  super(message);
@@ -56,59 +50,56 @@ var AppError = class extends Error {
56
50
  this.context = context;
57
51
  }
58
52
  };
59
- var AuthRequiredError = class extends AppError {
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- constructor(message = "Authentication required", context) {
62
- super(message, "AUTH_REQUIRED", 401, context);
63
- }
64
- };
65
- var TenantRequiredError = class extends AppError {
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
- constructor(message = "Tenant context required", context) {
68
- super(message, "TENANT_REQUIRED", 400, context);
69
- }
70
- };
71
- var PermissionDeniedError = class extends AppError {
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
- constructor(message = "Permission denied", context) {
74
- super(message, "PERMISSION_DENIED", 403, context);
53
+ function normalizeError(err, context) {
54
+ if (err instanceof AppError) {
55
+ return {
56
+ name: err.name,
57
+ message: err.message,
58
+ code: err.code,
59
+ statusCode: err.statusCode,
60
+ context: context ? { ...err.context, ...context } : err.context
61
+ };
75
62
  }
76
- };
77
- var ValidationError = class extends AppError {
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
- constructor(message, context) {
80
- super(message, "VALIDATION_ERROR", 400, context);
63
+ if (err instanceof Error) {
64
+ return {
65
+ name: err.name,
66
+ message: err.message,
67
+ code: "INTERNAL_ERROR",
68
+ statusCode: 500,
69
+ context
70
+ };
81
71
  }
82
- };
72
+ return {
73
+ name: "Error",
74
+ message: "Unknown error",
75
+ code: "INTERNAL_ERROR",
76
+ statusCode: 500,
77
+ context: context ? { ...context, originalError: err } : { originalError: err }
78
+ };
79
+ }
83
80
 
84
- // src/react-native.ts
81
+ // src/server/index.ts
85
82
  function initErrors(config) {
86
83
  Sentry.init({
87
84
  dsn: config.dsn,
88
- environment: config.environment || "production"
85
+ tracesSampleRate: config.tracesSampleRate ?? 1
89
86
  });
90
87
  }
91
88
  function setUserContext(user) {
92
89
  Sentry.setUser(user);
93
90
  }
94
91
  function captureError(err, context) {
92
+ const normalized = normalizeError(err, context);
95
93
  if (err instanceof AppError) {
96
- if (err.statusCode >= 500) {
97
- Sentry.captureException(err, { extra: { ...err.context, ...context } });
98
- } else {
99
- console.warn(`[${err.code}] ${err.message}`, { context: err.context, ...context });
94
+ if (normalized.statusCode >= 500) {
95
+ Sentry.captureException(err, { extra: normalized.context });
100
96
  }
101
- } else {
102
- Sentry.captureException(err, { extra: context });
97
+ return;
103
98
  }
99
+ Sentry.captureException(err, { extra: normalized.context });
104
100
  }
105
101
  // Annotate the CommonJS export names for ESM import in node:
106
102
  0 && (module.exports = {
107
- AppError,
108
- AuthRequiredError,
109
- PermissionDeniedError,
110
- TenantRequiredError,
111
- ValidationError,
112
103
  captureError,
113
104
  initErrors,
114
105
  setUserContext
@@ -0,0 +1,31 @@
1
+ import {
2
+ AppError,
3
+ normalizeError
4
+ } from "../chunk-SK2GZ7XR.mjs";
5
+
6
+ // src/server/index.ts
7
+ import * as Sentry from "@sentry/node";
8
+ function initErrors(config) {
9
+ Sentry.init({
10
+ dsn: config.dsn,
11
+ tracesSampleRate: config.tracesSampleRate ?? 1
12
+ });
13
+ }
14
+ function setUserContext(user) {
15
+ Sentry.setUser(user);
16
+ }
17
+ function captureError(err, context) {
18
+ const normalized = normalizeError(err, context);
19
+ if (err instanceof AppError) {
20
+ if (normalized.statusCode >= 500) {
21
+ Sentry.captureException(err, { extra: normalized.context });
22
+ }
23
+ return;
24
+ }
25
+ Sentry.captureException(err, { extra: normalized.context });
26
+ }
27
+ export {
28
+ captureError,
29
+ initErrors,
30
+ setUserContext
31
+ };
@@ -0,0 +1,29 @@
1
+ type ErrorContext = Record<string, any>;
2
+ interface NormalizedError {
3
+ name: string;
4
+ message: string;
5
+ code: string;
6
+ statusCode: number;
7
+ context?: ErrorContext;
8
+ }
9
+ declare class AppError extends Error {
10
+ readonly code: string;
11
+ readonly statusCode: number;
12
+ readonly context?: ErrorContext;
13
+ constructor(message: string, code: string, statusCode?: number, context?: ErrorContext);
14
+ }
15
+ declare class AuthRequiredError extends AppError {
16
+ constructor(message?: string, context?: ErrorContext);
17
+ }
18
+ declare class TenantRequiredError extends AppError {
19
+ constructor(message?: string, context?: ErrorContext);
20
+ }
21
+ declare class PermissionDeniedError extends AppError {
22
+ constructor(message?: string, context?: ErrorContext);
23
+ }
24
+ declare class ValidationError extends AppError {
25
+ constructor(message: string, context?: ErrorContext);
26
+ }
27
+ declare function normalizeError(err: unknown, context?: ErrorContext): NormalizedError;
28
+
29
+ export { AppError, AuthRequiredError, type ErrorContext, type NormalizedError, PermissionDeniedError, TenantRequiredError, ValidationError, normalizeError };
@@ -0,0 +1,29 @@
1
+ type ErrorContext = Record<string, any>;
2
+ interface NormalizedError {
3
+ name: string;
4
+ message: string;
5
+ code: string;
6
+ statusCode: number;
7
+ context?: ErrorContext;
8
+ }
9
+ declare class AppError extends Error {
10
+ readonly code: string;
11
+ readonly statusCode: number;
12
+ readonly context?: ErrorContext;
13
+ constructor(message: string, code: string, statusCode?: number, context?: ErrorContext);
14
+ }
15
+ declare class AuthRequiredError extends AppError {
16
+ constructor(message?: string, context?: ErrorContext);
17
+ }
18
+ declare class TenantRequiredError extends AppError {
19
+ constructor(message?: string, context?: ErrorContext);
20
+ }
21
+ declare class PermissionDeniedError extends AppError {
22
+ constructor(message?: string, context?: ErrorContext);
23
+ }
24
+ declare class ValidationError extends AppError {
25
+ constructor(message: string, context?: ErrorContext);
26
+ }
27
+ declare function normalizeError(err: unknown, context?: ErrorContext): NormalizedError;
28
+
29
+ export { AppError, AuthRequiredError, type ErrorContext, type NormalizedError, PermissionDeniedError, TenantRequiredError, ValidationError, normalizeError };
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,36 +15,24 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
- // src/node.ts
31
- var node_exports = {};
32
- __export(node_exports, {
20
+ // src/shared/index.ts
21
+ var shared_exports = {};
22
+ __export(shared_exports, {
33
23
  AppError: () => AppError,
34
24
  AuthRequiredError: () => AuthRequiredError,
35
25
  PermissionDeniedError: () => PermissionDeniedError,
36
26
  TenantRequiredError: () => TenantRequiredError,
37
27
  ValidationError: () => ValidationError,
38
- captureError: () => captureError,
39
- initErrors: () => initErrors,
40
- setUserContext: () => setUserContext
28
+ normalizeError: () => normalizeError
41
29
  });
42
- module.exports = __toCommonJS(node_exports);
43
- var Sentry = __toESM(require("@sentry/node"));
30
+ module.exports = __toCommonJS(shared_exports);
44
31
 
45
- // src/shared.ts
32
+ // src/shared/types.ts
46
33
  var AppError = class extends Error {
47
34
  code;
48
35
  statusCode;
49
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
36
  context;
51
37
  constructor(message, code, statusCode = 500, context) {
52
38
  super(message);
@@ -57,50 +43,51 @@ var AppError = class extends Error {
57
43
  }
58
44
  };
59
45
  var AuthRequiredError = class extends AppError {
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
46
  constructor(message = "Authentication required", context) {
62
47
  super(message, "AUTH_REQUIRED", 401, context);
63
48
  }
64
49
  };
65
50
  var TenantRequiredError = class extends AppError {
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
51
  constructor(message = "Tenant context required", context) {
68
52
  super(message, "TENANT_REQUIRED", 400, context);
69
53
  }
70
54
  };
71
55
  var PermissionDeniedError = class extends AppError {
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
56
  constructor(message = "Permission denied", context) {
74
57
  super(message, "PERMISSION_DENIED", 403, context);
75
58
  }
76
59
  };
77
60
  var ValidationError = class extends AppError {
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
61
  constructor(message, context) {
80
62
  super(message, "VALIDATION_ERROR", 400, context);
81
63
  }
82
64
  };
83
-
84
- // src/node.ts
85
- function captureError(err, context) {
65
+ function normalizeError(err, context) {
86
66
  if (err instanceof AppError) {
87
- console.warn(`[${err.code}] ${err.message}`, { context: err.context, ...context });
88
- if (err.statusCode >= 500) {
89
- Sentry.captureException(err, { extra: { ...err.context, ...context } });
90
- }
91
- } else {
92
- console.error("Unexpected error:", err);
93
- Sentry.captureException(err, { extra: context });
67
+ return {
68
+ name: err.name,
69
+ message: err.message,
70
+ code: err.code,
71
+ statusCode: err.statusCode,
72
+ context: context ? { ...err.context, ...context } : err.context
73
+ };
94
74
  }
95
- }
96
- function setUserContext(user) {
97
- Sentry.setUser(user);
98
- }
99
- function initErrors(dsn) {
100
- Sentry.init({
101
- dsn,
102
- tracesSampleRate: 1
103
- });
75
+ if (err instanceof Error) {
76
+ return {
77
+ name: err.name,
78
+ message: err.message,
79
+ code: "INTERNAL_ERROR",
80
+ statusCode: 500,
81
+ context
82
+ };
83
+ }
84
+ return {
85
+ name: "Error",
86
+ message: "Unknown error",
87
+ code: "INTERNAL_ERROR",
88
+ statusCode: 500,
89
+ context: context ? { ...context, originalError: err } : { originalError: err }
90
+ };
104
91
  }
105
92
  // Annotate the CommonJS export names for ESM import in node:
106
93
  0 && (module.exports = {
@@ -109,7 +96,5 @@ function initErrors(dsn) {
109
96
  PermissionDeniedError,
110
97
  TenantRequiredError,
111
98
  ValidationError,
112
- captureError,
113
- initErrors,
114
- setUserContext
99
+ normalizeError
115
100
  });
@@ -0,0 +1,16 @@
1
+ import {
2
+ AppError,
3
+ AuthRequiredError,
4
+ PermissionDeniedError,
5
+ TenantRequiredError,
6
+ ValidationError,
7
+ normalizeError
8
+ } from "../chunk-SK2GZ7XR.mjs";
9
+ export {
10
+ AppError,
11
+ AuthRequiredError,
12
+ PermissionDeniedError,
13
+ TenantRequiredError,
14
+ ValidationError,
15
+ normalizeError
16
+ };