keryx 0.24.2 → 0.25.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/classes/API.ts +6 -6
- package/classes/Connection.ts +2 -2
- package/classes/TypedError.ts +12 -12
- package/package.json +1 -1
- package/util/glob.ts +1 -1
- package/util/transaction.ts +1 -1
- package/util/webRouting.ts +1 -1
- package/util/webSocket.ts +2 -2
package/classes/API.ts
CHANGED
|
@@ -86,9 +86,9 @@ export class API {
|
|
|
86
86
|
this.logger.debug(`Initialized initializer ${initializer.name}`);
|
|
87
87
|
} catch (e) {
|
|
88
88
|
throw new TypedError({
|
|
89
|
-
message:
|
|
89
|
+
message: `Failed to initialize initializer "${initializer.name}": ${e instanceof Error ? e.message : e}`,
|
|
90
90
|
type: ErrorType.SERVER_INITIALIZATION,
|
|
91
|
-
|
|
91
|
+
cause: e,
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -132,9 +132,9 @@ export class API {
|
|
|
132
132
|
this.logger.debug(`Started initializer ${initializer.name}`);
|
|
133
133
|
} catch (e) {
|
|
134
134
|
throw new TypedError({
|
|
135
|
-
message:
|
|
135
|
+
message: `Failed to start initializer "${initializer.name}": ${e instanceof Error ? e.message : e}`,
|
|
136
136
|
type: ErrorType.SERVER_START,
|
|
137
|
-
|
|
137
|
+
cause: e,
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -167,9 +167,9 @@ export class API {
|
|
|
167
167
|
this.logger.debug(`Stopped initializer ${initializer.name}`);
|
|
168
168
|
} catch (e) {
|
|
169
169
|
throw new TypedError({
|
|
170
|
-
message:
|
|
170
|
+
message: `Failed to stop initializer "${initializer.name}": ${e instanceof Error ? e.message : e}`,
|
|
171
171
|
type: ErrorType.SERVER_STOP,
|
|
172
|
-
|
|
172
|
+
cause: e,
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
}
|
package/classes/Connection.ts
CHANGED
|
@@ -161,7 +161,7 @@ export class Connection<
|
|
|
161
161
|
: new TypedError({
|
|
162
162
|
message: `${e}`,
|
|
163
163
|
type: ErrorType.CONNECTION_ACTION_RUN,
|
|
164
|
-
|
|
164
|
+
cause: e,
|
|
165
165
|
});
|
|
166
166
|
} finally {
|
|
167
167
|
if (action && formattedParams) {
|
|
@@ -337,7 +337,7 @@ export class Connection<
|
|
|
337
337
|
throw new TypedError({
|
|
338
338
|
message: `Error validating params: ${e}`,
|
|
339
339
|
type: ErrorType.CONNECTION_ACTION_PARAM_VALIDATION,
|
|
340
|
-
|
|
340
|
+
cause: e,
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
343
|
}
|
package/classes/TypedError.ts
CHANGED
|
@@ -73,8 +73,11 @@ export type TypedErrorArgs = {
|
|
|
73
73
|
message: string;
|
|
74
74
|
/** The error category, which determines the HTTP status code. */
|
|
75
75
|
type: ErrorType;
|
|
76
|
-
/**
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* The underlying error being wrapped. Exposed via the standard ES2022 `Error.cause`
|
|
78
|
+
* field, so `console.error(err)` prints the full "Caused by:" chain natively.
|
|
79
|
+
*/
|
|
80
|
+
cause?: unknown;
|
|
78
81
|
/** The param key that caused the error (for validation errors). */
|
|
79
82
|
key?: string;
|
|
80
83
|
/** The param value that caused the error (for validation errors). */
|
|
@@ -84,7 +87,9 @@ export type TypedErrorArgs = {
|
|
|
84
87
|
/**
|
|
85
88
|
* Structured error class for action and framework failures. Extends `Error` with an
|
|
86
89
|
* `ErrorType` that maps to an HTTP status code, and optional `key`/`value` fields for
|
|
87
|
-
* param validation errors.
|
|
90
|
+
* param validation errors. When `cause` is provided, it is forwarded to the base
|
|
91
|
+
* `Error` constructor so the native ES2022 cause chain is preserved — tooling that
|
|
92
|
+
* inspects errors (Node's default printer, debuggers) will walk both stacks.
|
|
88
93
|
*/
|
|
89
94
|
export class TypedError extends Error {
|
|
90
95
|
/** The error category, used to determine the HTTP status code via `ErrorStatusCodes`. */
|
|
@@ -95,17 +100,12 @@ export class TypedError extends Error {
|
|
|
95
100
|
value?: any;
|
|
96
101
|
|
|
97
102
|
constructor(args: TypedErrorArgs) {
|
|
98
|
-
super(
|
|
103
|
+
super(
|
|
104
|
+
args.message,
|
|
105
|
+
args.cause !== undefined ? { cause: args.cause } : undefined,
|
|
106
|
+
);
|
|
99
107
|
this.type = args.type;
|
|
100
108
|
this.key = args.key;
|
|
101
109
|
this.value = args.value;
|
|
102
|
-
|
|
103
|
-
if (args.originalError !== undefined) {
|
|
104
|
-
if (args.originalError instanceof Error) {
|
|
105
|
-
this.stack = args.originalError.stack;
|
|
106
|
-
} else {
|
|
107
|
-
this.stack = `OriginalStringError: ${args.originalError}`;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
110
|
}
|
|
111
111
|
}
|
package/package.json
CHANGED
package/util/glob.ts
CHANGED
package/util/transaction.ts
CHANGED
package/util/webRouting.ts
CHANGED
package/util/webSocket.ts
CHANGED
|
@@ -122,7 +122,7 @@ export async function handleWebsocketSubscribe(
|
|
|
122
122
|
: new TypedError({
|
|
123
123
|
message: `${e}`,
|
|
124
124
|
type: ErrorType.CONNECTION_CHANNEL_AUTHORIZATION,
|
|
125
|
-
|
|
125
|
+
cause: e,
|
|
126
126
|
});
|
|
127
127
|
ws.send(
|
|
128
128
|
JSON.stringify({
|
|
@@ -174,7 +174,7 @@ export async function handleWebsocketUnsubscribe(
|
|
|
174
174
|
: new TypedError({
|
|
175
175
|
message: `${e}`,
|
|
176
176
|
type: ErrorType.CONNECTION_CHANNEL_VALIDATION,
|
|
177
|
-
|
|
177
|
+
cause: e,
|
|
178
178
|
});
|
|
179
179
|
ws.send(
|
|
180
180
|
JSON.stringify({
|