@wrelik/errors 0.2.1 → 2.0.1
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.
- package/.turbo/turbo-build.log +26 -28
- package/.turbo/turbo-lint.log +35 -0
- package/.turbo/turbo-test.log +16 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-EARDCOC4.mjs → chunk-SK2GZ7XR.mjs} +30 -7
- package/dist/client/index.d.mts +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +70 -0
- package/dist/client/index.mjs +6 -0
- package/dist/server/index.d.mts +13 -0
- package/dist/server/index.d.ts +13 -0
- package/dist/{react-native.js → server/index.js} +38 -47
- package/dist/server/index.mjs +31 -0
- package/dist/shared/index.d.mts +29 -0
- package/dist/shared/index.d.ts +29 -0
- package/dist/{node.js → shared/index.js} +31 -46
- package/dist/shared/index.mjs +16 -0
- package/package.json +34 -18
- package/src/client/index.test.ts +18 -0
- package/src/client/index.ts +2 -0
- package/src/server/index.test.ts +40 -0
- package/src/server/index.ts +26 -0
- package/src/shared/index.test.ts +37 -0
- package/src/shared/index.ts +9 -0
- package/src/shared/types.ts +78 -0
- package/tsconfig.json +2 -1
- package/dist/browser.d.mts +0 -10
- package/dist/browser.d.ts +0 -10
- package/dist/browser.js +0 -115
- package/dist/browser.mjs +0 -40
- package/dist/node.d.mts +0 -10
- package/dist/node.d.ts +0 -10
- package/dist/node.mjs +0 -40
- package/dist/react-native.d.mts +0 -13
- package/dist/react-native.d.ts +0 -13
- package/dist/react-native.mjs +0 -40
- package/dist/shared-DXFP3J32.d.mts +0 -20
- package/dist/shared-DXFP3J32.d.ts +0 -20
- package/src/browser.ts +0 -31
- package/src/node.ts +0 -31
- package/src/react-native.ts +0 -28
- package/src/shared.ts +0 -49
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
|
|
2
|
-
> @wrelik/errors@0.
|
|
3
|
-
> tsup src/
|
|
2
|
+
> @wrelik/errors@2.0.1 build /Users/lee/Projects/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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[32mDTS[39m [1mdist/react-native.d.mts [22m[32m476.00 B[39m
|
|
30
|
-
[32mDTS[39m [1mdist/shared-DXFP3J32.d.mts [22m[32m851.00 B[39m
|
|
5
|
+
CLI Building entry: src/server/index.ts, src/client/index.ts, src/shared/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.1
|
|
8
|
+
CLI Target: es2022
|
|
9
|
+
CLI Cleaning output folder
|
|
10
|
+
CJS Build start
|
|
11
|
+
ESM Build start
|
|
12
|
+
DTS Build start
|
|
13
|
+
ESM dist/server/index.mjs 693.00 B
|
|
14
|
+
ESM dist/client/index.mjs 87.00 B
|
|
15
|
+
ESM dist/shared/index.mjs 287.00 B
|
|
16
|
+
ESM dist/chunk-SK2GZ7XR.mjs 1.68 KB
|
|
17
|
+
ESM ⚡️ Build success in 1918ms
|
|
18
|
+
CJS dist/client/index.js 1.96 KB
|
|
19
|
+
CJS dist/server/index.js 3.20 KB
|
|
20
|
+
CJS dist/shared/index.js 2.91 KB
|
|
21
|
+
CJS ⚡️ Build success in 1919ms
|
|
22
|
+
DTS ⚡️ Build success in 4132ms
|
|
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
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
> @wrelik/errors@0.2.1 lint /Users/lee/Projects/wrelik-kit/packages/errors
|
|
3
|
+
> eslint src/
|
|
4
|
+
|
|
5
|
+
Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.
|
|
6
|
+
|
|
7
|
+
/Users/lee/Projects/wrelik-kit/packages/errors/src/client.test.ts
|
|
8
|
+
3:1 warning '@sentry/browser' import is restricted from being used. Please use @wrelik/errors/client instead no-restricted-imports
|
|
9
|
+
|
|
10
|
+
/Users/lee/Projects/wrelik-kit/packages/errors/src/client.ts
|
|
11
|
+
5:1 warning '@sentry/browser' import is restricted from being used. Please use @wrelik/errors/client instead no-restricted-imports
|
|
12
|
+
31:105 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
13
|
+
48:18 warning '_' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
14
|
+
48:34 warning '__' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
15
|
+
48:56 warning '___' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
16
|
+
|
|
17
|
+
/Users/lee/Projects/wrelik-kit/packages/errors/src/react-native.test.ts
|
|
18
|
+
3:1 warning '@sentry/react-native' import is restricted from being used. Please use @wrelik/errors/react-native instead no-restricted-imports
|
|
19
|
+
|
|
20
|
+
/Users/lee/Projects/wrelik-kit/packages/errors/src/react-native.ts
|
|
21
|
+
5:1 warning '@sentry/react-native' import is restricted from being used. Please use @wrelik/errors/react-native instead no-restricted-imports
|
|
22
|
+
11:105 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
23
|
+
28:18 warning '_' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
24
|
+
28:34 warning '__' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
25
|
+
28:56 warning '___' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
26
|
+
|
|
27
|
+
/Users/lee/Projects/wrelik-kit/packages/errors/src/server.ts
|
|
28
|
+
5:1 warning '@sentry/node' import is restricted from being used. Please use @wrelik/errors/server instead no-restricted-imports
|
|
29
|
+
31:105 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
30
|
+
48:18 warning '_' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
31
|
+
48:34 warning '__' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
32
|
+
48:56 warning '___' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
33
|
+
|
|
34
|
+
✖ 17 problems (0 errors, 17 warnings)
|
|
35
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
> @wrelik/errors@2.0.1 test /Users/lee/Projects/wrelik-kit/packages/errors
|
|
3
|
+
> vitest run --passWithNoTests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[1m[46m RUN [49m[22m [36mv4.1.2 [39m[90m/Users/lee/Projects/wrelik-kit/packages/errors[39m
|
|
7
|
+
|
|
8
|
+
[32m✓[39m src/server/index.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 172[2mms[22m[39m
|
|
9
|
+
[32m✓[39m src/shared/index.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
10
|
+
[32m✓[39m src/client/index.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
11
|
+
|
|
12
|
+
[2m Test Files [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
|
13
|
+
[2m Tests [22m [1m[32m7 passed[39m[22m[90m (7)[39m
|
|
14
|
+
[2m Start at [22m 20:04:57
|
|
15
|
+
[2m Duration [22m 1.34s[2m (transform 728ms, setup 0ms, import 904ms, tests 187ms, environment 0ms)[22m
|
|
16
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @wrelik/errors
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3262454: Upgrade runtime SDK and workspace tooling dependencies to latest compatible versions, including Clerk, Sentry, AWS SDK, Inngest, Resend, Upstash, Zod, TypeScript, Turbo, Vitest, TSUP, and ESLint.
|
|
8
|
+
|
|
9
|
+
Adopt root ESLint flat config and align wrapper peer ranges for updated SDK majors while preserving package export paths. Also apply a patched transitive Next.js resolution to close audit findings and keep production audit clean.
|
|
10
|
+
|
|
11
|
+
Note: Vite is pinned to the latest 7.x line for runtime compatibility in this environment; this avoids current rolldown native-binding failures seen with Vite 8 under Node 20.18.0.
|
|
12
|
+
|
|
13
|
+
Breaking change: `@wrelik/auth` and `@wrelik/clerk-next` now require `@clerk/nextjs@7.x` via updated peer ranges (`>=7 <8`). Consumers on Clerk v4-v6 must upgrade to Clerk v7 before adopting these versions.
|
|
14
|
+
|
|
15
|
+
## 2.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- 818ed58: Refactor runtime packages to strict subpath exports (`/server`, `/client`, `/shared`) with side-effect free entrypoints and hard CI/runtime boundary enforcement.
|
|
20
|
+
|
|
3
21
|
## 0.2.1
|
|
4
22
|
|
|
5
23
|
### Patch 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,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/
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
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(
|
|
43
|
-
var Sentry = __toESM(require("@sentry/
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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/
|
|
81
|
+
// src/server/index.ts
|
|
85
82
|
function initErrors(config) {
|
|
86
83
|
Sentry.init({
|
|
87
84
|
dsn: config.dsn,
|
|
88
|
-
|
|
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 (
|
|
97
|
-
Sentry.captureException(err, { extra:
|
|
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
|
-
|
|
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 };
|