@cyanheads/mcp-ts-core 0.13.12 → 0.13.13
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/AGENTS.md +7 -6
- package/CLAUDE.md +7 -6
- package/README.md +1 -1
- package/changelog/0.13.x/0.13.13.md +93 -0
- package/dist/core/context.d.ts +12 -0
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +59 -14
- package/dist/core/context.js.map +1 -1
- package/dist/core/worker.d.ts.map +1 -1
- package/dist/core/worker.js +21 -8
- package/dist/core/worker.js.map +1 -1
- package/dist/mcp-server/inputRequired.d.ts +18 -9
- package/dist/mcp-server/inputRequired.d.ts.map +1 -1
- package/dist/mcp-server/inputRequired.js +29 -15
- package/dist/mcp-server/inputRequired.js.map +1 -1
- package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -1
- package/dist/mcp-server/prompts/prompt-registration.js +10 -7
- package/dist/mcp-server/prompts/prompt-registration.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +22 -9
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +7 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +34 -19
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/mcp-server/transports/auth/lib/authUtils.d.ts +3 -1
- package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/lib/authUtils.js +4 -2
- package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts.map +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.js +48 -21
- package/dist/storage/providers/fileSystem/fileSystemProvider.js.map +1 -1
- package/dist/types-global/errors.d.ts.map +1 -1
- package/dist/types-global/errors.js +31 -16
- package/dist/types-global/errors.js.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.d.ts +29 -12
- package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.js +198 -100
- package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
- package/dist/utils/internal/error-handler/helpers.d.ts +75 -4
- package/dist/utils/internal/error-handler/helpers.d.ts.map +1 -1
- package/dist/utils/internal/error-handler/helpers.js +232 -33
- package/dist/utils/internal/error-handler/helpers.js.map +1 -1
- package/dist/utils/internal/error-handler/types.d.ts +17 -7
- package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
- package/dist/utils/internal/logValue.d.ts +33 -0
- package/dist/utils/internal/logValue.d.ts.map +1 -0
- package/dist/utils/internal/logValue.js +539 -0
- package/dist/utils/internal/logValue.js.map +1 -0
- package/dist/utils/internal/logger.d.ts +38 -9
- package/dist/utils/internal/logger.d.ts.map +1 -1
- package/dist/utils/internal/logger.js +228 -118
- package/dist/utils/internal/logger.js.map +1 -1
- package/dist/utils/internal/performance.d.ts.map +1 -1
- package/dist/utils/internal/performance.js +9 -11
- package/dist/utils/internal/performance.js.map +1 -1
- package/dist/utils/internal/requestContext.d.ts +3 -3
- package/dist/utils/internal/requestContext.js +1 -1
- package/dist/utils/network/fetchWithTimeout.d.ts +18 -10
- package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
- package/dist/utils/network/fetchWithTimeout.js +48 -20
- package/dist/utils/network/fetchWithTimeout.js.map +1 -1
- package/dist/utils/network/httpError.d.ts +8 -6
- package/dist/utils/network/httpError.d.ts.map +1 -1
- package/dist/utils/network/httpError.js +23 -7
- package/dist/utils/network/httpError.js.map +1 -1
- package/dist/utils/network/retry.d.ts +7 -4
- package/dist/utils/network/retry.d.ts.map +1 -1
- package/dist/utils/network/retry.js +24 -10
- package/dist/utils/network/retry.js.map +1 -1
- package/dist/utils/security/sanitization.d.ts +24 -28
- package/dist/utils/security/sanitization.d.ts.map +1 -1
- package/dist/utils/security/sanitization.js +25 -84
- package/dist/utils/security/sanitization.js.map +1 -1
- package/dist/utils/security/sensitiveFields.d.ts +32 -4
- package/dist/utils/security/sensitiveFields.d.ts.map +1 -1
- package/dist/utils/security/sensitiveFields.js +85 -4
- package/dist/utils/security/sensitiveFields.js.map +1 -1
- package/dist/utils/telemetry/trace.d.ts +3 -1
- package/dist/utils/telemetry/trace.d.ts.map +1 -1
- package/dist/utils/telemetry/trace.js +6 -6
- package/dist/utils/telemetry/trace.js.map +1 -1
- package/framework-skills/api-config/SKILL.md +2 -1
- package/framework-skills/api-context/SKILL.md +3 -3
- package/framework-skills/api-errors/SKILL.md +17 -15
- package/framework-skills/api-linter/SKILL.md +11 -10
- package/framework-skills/api-telemetry/SKILL.md +6 -4
- package/framework-skills/api-utils/SKILL.md +6 -6
- package/framework-skills/api-utils/references/security.md +4 -2
- package/package.json +6 -5
- package/scripts/check-framework-antipatterns.ts +3 -2
- package/templates/.env.example +2 -0
- package/templates/tests/tools/echo.tool.test.ts +19 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../../../src/utils/internal/error-handler/errorHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAE,gBAAgB,EAA8B,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../../../src/utils/internal/error-handler/errorHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAE,gBAAgB,EAA8B,MAAM,0BAA0B,CAAC;AAmCxF,OAAO,KAAK,EAAgB,mBAAmB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAalF,0FAA0F;AAC1F,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AA8BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;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mB,EAAE,SAAS,CAAC,GAC5C,OAAO,CAAC,CAAC,CAAC,CAUZ;CACF"}
|
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
* @module src/utils/internal/error-handler/errorHandler
|
|
5
5
|
*/
|
|
6
6
|
import { SdkError, SdkErrorCode } from '@modelcontextprotocol/server';
|
|
7
|
-
import {
|
|
7
|
+
import { trace } from '@opentelemetry/api';
|
|
8
8
|
import { ZodError } from 'zod';
|
|
9
9
|
import { isInputRequiredSignal } from '../../../mcp-server/inputRequired.js';
|
|
10
10
|
import { JsonRpcErrorCode, McpError, requestCancelled } from '../../../types-global/errors.js';
|
|
11
11
|
import { logger } from '../logger.js';
|
|
12
|
+
import { toLogValue } from '../logValue.js';
|
|
12
13
|
import { generateUUID } from '../../security/idGenerator.js';
|
|
13
14
|
import { sanitizeInputForLogging } from '../../security/sanitization.js';
|
|
14
15
|
import { ATTR_MCP_ERROR_CATEGORY, ATTR_MCP_ERROR_CLASSIFIED_CODE, ATTR_MCP_ERROR_SEVERITY, } from '../../telemetry/attributes.js';
|
|
15
16
|
import { createCounter } from '../../telemetry/metrics.js';
|
|
16
|
-
import {
|
|
17
|
+
import { isRecord } from '../../types/guards.js';
|
|
18
|
+
import { asError, copyFields, errorText, extractErrorCauseChain, getErrorMessage, getErrorName, isInstance, readErrorData, readField, readWireErrorData, recordSpanFailure, UNREADABLE, } from './helpers.js';
|
|
17
19
|
import { COMPILED_ERROR_PATTERNS, COMPILED_PROVIDER_PATTERNS, ENGINE_RESOURCE_LIMIT_MESSAGES, ERROR_TYPE_MAPPINGS, getCompiledPattern, getErrorCategory, } from './mappings.js';
|
|
18
20
|
let errorClassifiedCounter;
|
|
19
21
|
function getErrorMetrics() {
|
|
@@ -24,11 +26,33 @@ function getErrorMetrics() {
|
|
|
24
26
|
export function initErrorMetrics() {
|
|
25
27
|
getErrorMetrics();
|
|
26
28
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* A record's `extra` as a stack-free record writes it, every field in one walk
|
|
31
|
+
* — the context's, `input`, `errorData`: each `Error` written without its
|
|
32
|
+
* `stack`, no `stack`, and none of `errorData`'s stack fields (`originalStack`,
|
|
33
|
+
* and on each `causeChain` node its `stack` and the same fields in its `data`).
|
|
34
|
+
* `extra` is the record's own object literal, so the walk returns an object
|
|
35
|
+
* whatever the context's `extra` was.
|
|
36
|
+
*/
|
|
37
|
+
function toStackFreeExtra(extra) {
|
|
38
|
+
const { stack: _stack, ...rest } = toLogValue(extra, { includeStack: false });
|
|
39
|
+
if (isRecord(rest.errorData))
|
|
40
|
+
dropStackFields(rest.errorData);
|
|
30
41
|
return rest;
|
|
31
42
|
}
|
|
43
|
+
/** Deletes the record's stack fields from `data`, a walked copy, down its `causeChain`. */
|
|
44
|
+
function dropStackFields(data) {
|
|
45
|
+
delete data.originalStack;
|
|
46
|
+
if (!Array.isArray(data.causeChain))
|
|
47
|
+
return;
|
|
48
|
+
for (const node of data.causeChain) {
|
|
49
|
+
if (!isRecord(node))
|
|
50
|
+
continue;
|
|
51
|
+
delete node.stack;
|
|
52
|
+
if (isRecord(node.data))
|
|
53
|
+
dropStackFields(node.data);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
32
56
|
/**
|
|
33
57
|
* The value a handler unwound with, resolved against its request's cancellation.
|
|
34
58
|
*
|
|
@@ -63,8 +87,10 @@ function withoutKey(record, key) {
|
|
|
63
87
|
export function asRequestCancelled(error, signal) {
|
|
64
88
|
if (!signal.aborted || isInputRequiredSignal(error))
|
|
65
89
|
return error;
|
|
66
|
-
if (error
|
|
90
|
+
if (isInstance(error, McpError) &&
|
|
91
|
+
readField(error, 'code') === JsonRpcErrorCode.RequestCancelled) {
|
|
67
92
|
return error;
|
|
93
|
+
}
|
|
68
94
|
return requestCancelled(getErrorMessage(error), undefined, { cause: error });
|
|
69
95
|
}
|
|
70
96
|
/**
|
|
@@ -81,7 +107,7 @@ export class ErrorHandler {
|
|
|
81
107
|
* which outranks every step below.
|
|
82
108
|
*
|
|
83
109
|
* Resolution order:
|
|
84
|
-
* 1. `McpError` instances — returns `error.code` directly.
|
|
110
|
+
* 1. `McpError` instances — returns `error.code` directly (`InternalError` when the code cannot be read).
|
|
85
111
|
* 2. SDK `ConnectionClosed` rejections — mapped to `RequestCancelled`, ahead of the pattern ladder.
|
|
86
112
|
* 3. Engine resource-limit `RangeError`s — a whole message in `ENGINE_RESOURCE_LIMIT_MESSAGES`
|
|
87
113
|
* (stack overflow, maximum string size) maps to `InternalError` (#482).
|
|
@@ -107,8 +133,14 @@ export class ErrorHandler {
|
|
|
107
133
|
* ```
|
|
108
134
|
*/
|
|
109
135
|
static determineErrorCode(error) {
|
|
110
|
-
|
|
111
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Every read of the thrown value is guarded (#697): a value `instanceof`
|
|
138
|
+
* cannot inspect (a revoked `Proxy`) is classified as a non-Error, and a
|
|
139
|
+
* field whose read throws as `'[Unreadable]'`.
|
|
140
|
+
*/
|
|
141
|
+
if (isInstance(error, McpError)) {
|
|
142
|
+
const code = readField(error, 'code');
|
|
143
|
+
return code === UNREADABLE ? JsonRpcErrorCode.InternalError : code;
|
|
112
144
|
}
|
|
113
145
|
/**
|
|
114
146
|
* The SDK rejects every request still in flight when the transport closes,
|
|
@@ -117,7 +149,7 @@ export class ErrorHandler {
|
|
|
117
149
|
* one wording, and the one that says "aborted" would otherwise be caught by
|
|
118
150
|
* the generic abort pattern below and read as a `Timeout`.
|
|
119
151
|
*/
|
|
120
|
-
if (error
|
|
152
|
+
if (isInstance(error, SdkError) && readField(error, 'code') === SdkErrorCode.ConnectionClosed) {
|
|
121
153
|
return JsonRpcErrorCode.RequestCancelled;
|
|
122
154
|
}
|
|
123
155
|
const errorName = getErrorName(error);
|
|
@@ -149,10 +181,7 @@ export class ErrorHandler {
|
|
|
149
181
|
}
|
|
150
182
|
}
|
|
151
183
|
// Special-case common platform errors
|
|
152
|
-
if (typeof error === 'object' &&
|
|
153
|
-
error !== null &&
|
|
154
|
-
'name' in error &&
|
|
155
|
-
error.name === 'AbortError') {
|
|
184
|
+
if (typeof error === 'object' && error !== null && readField(error, 'name') === 'AbortError') {
|
|
156
185
|
return JsonRpcErrorCode.Timeout;
|
|
157
186
|
}
|
|
158
187
|
return JsonRpcErrorCode.InternalError;
|
|
@@ -163,15 +192,24 @@ export class ErrorHandler {
|
|
|
163
192
|
* Steps performed:
|
|
164
193
|
* 1. Records the exception on the active OTel span and sets span status to ERROR.
|
|
165
194
|
* 2. Sanitizes `options.input` via `sanitizeInputForLogging` before including in logs.
|
|
166
|
-
* 3. Extracts and consolidates error data
|
|
195
|
+
* 3. Extracts and consolidates error data and the full cause chain.
|
|
167
196
|
* 4. Rebuilds the error as a new `McpError` carrying the consolidated data — the thrown
|
|
168
|
-
* error's own `data`, `originalErrorName`,
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* `
|
|
197
|
+
* error's own `data`, `originalErrorName`, and `originalMessage` — preserving the classified
|
|
198
|
+
* code (or delegates to `options.errorMapper`). That `data` is client-visible once the error
|
|
199
|
+
* is thrown toward a handler, so it carries nothing derived from a cause, no stack, and no
|
|
200
|
+
* `context`: `rootCause`, `causeChain`, and the context ride the log record only. The
|
|
201
|
+
* rebuilt error takes the thrown error's stack, so it starts at the throw site.
|
|
172
202
|
* 5. Logs the result via the global logger with full structured context — at `error` level,
|
|
173
|
-
*
|
|
174
|
-
*
|
|
203
|
+
* with the throw site's stack as the record's `stack` (none for a thrown value without one,
|
|
204
|
+
* and never a context's `extra.stack`), and each stack written once: a `causeChain` node
|
|
205
|
+
* carrying the record's stack, or the same stack as the node before it, is written without
|
|
206
|
+
* it. The handler's own fields lead the record, ahead of the context's `extra` and `input`,
|
|
207
|
+
* and no caller key replaces one. A field of the thrown value whose read throws is written
|
|
208
|
+
* as `'[Unreadable]'`, so the call never throws on what it reports.
|
|
209
|
+
* A record is stack-free for `RequestCancelled`, which is a routine caller disconnect logged
|
|
210
|
+
* at `info`, and under `includeStack: false`: no `stack`, no `errorData.originalStack`, no
|
|
211
|
+
* `causeChain` node `stack` nor `originalStack` in a node's `data`, and every `Error` in the
|
|
212
|
+
* record written without its `stack` (see `ErrorHandlerOptions`).
|
|
175
213
|
* 6. Returns the processed error, or rethrows it if `options.rethrow` is `true`.
|
|
176
214
|
*
|
|
177
215
|
* @param error - The error instance or value that occurred.
|
|
@@ -197,34 +235,42 @@ export class ErrorHandler {
|
|
|
197
235
|
// --- OpenTelemetry Integration ---
|
|
198
236
|
// Skip ended/no-op spans — measure*Execution paths already record + end the span before re-throwing.
|
|
199
237
|
const activeSpan = trace.getActiveSpan();
|
|
200
|
-
if (activeSpan?.isRecording())
|
|
201
|
-
|
|
202
|
-
activeSpan.recordException(error);
|
|
203
|
-
}
|
|
204
|
-
activeSpan.setStatus({
|
|
205
|
-
code: SpanStatusCode.ERROR,
|
|
206
|
-
message: error instanceof Error ? error.message : String(error),
|
|
207
|
-
});
|
|
208
|
-
}
|
|
238
|
+
if (activeSpan?.isRecording())
|
|
239
|
+
recordSpanFailure(activeSpan, error);
|
|
209
240
|
// --- End OpenTelemetry Integration ---
|
|
210
241
|
const { context = {}, operation, input, rethrow = false, errorCode: explicitErrorCode, includeStack = true, critical = false, errorMapper, severity, } = options;
|
|
211
242
|
const sanitizedInput = input !== undefined ? sanitizeInputForLogging(input) : undefined;
|
|
243
|
+
/**
|
|
244
|
+
* Every read of the thrown value is guarded: a `name`, `message`, `stack`,
|
|
245
|
+
* `cause`, or an `McpError`'s `code` whose read throws (a getter, a revoked
|
|
246
|
+
* `Proxy`), or a `data` that cannot be read or copied, is written as
|
|
247
|
+
* `'[Unreadable]'` or left out, and a value `instanceof` cannot inspect is
|
|
248
|
+
* handled as a non-Error, so reporting a failure never fails itself (#697).
|
|
249
|
+
*/
|
|
212
250
|
const originalErrorName = getErrorName(error);
|
|
213
251
|
const originalErrorMessage = getErrorMessage(error);
|
|
214
|
-
const
|
|
252
|
+
const thrownError = isInstance(error, Error) ? error : undefined;
|
|
253
|
+
const thrownMcpError = isInstance(error, McpError) ? error : undefined;
|
|
254
|
+
const originalStack = thrownError ? readField(thrownError, 'stack') : undefined;
|
|
215
255
|
/**
|
|
216
256
|
* Classified before the record is assembled, because the code decides more
|
|
217
257
|
* than the wire response: a caller-abandoned request is a routine event, so
|
|
218
258
|
* it is logged at `info` and carries no stack. Attaching one invites triage
|
|
219
259
|
* to read a client hanging up as a fault in this server.
|
|
220
260
|
*/
|
|
221
|
-
const loggedErrorCode =
|
|
222
|
-
?
|
|
261
|
+
const loggedErrorCode = thrownMcpError
|
|
262
|
+
? ErrorHandler.determineErrorCode(thrownMcpError)
|
|
223
263
|
: explicitErrorCode || ErrorHandler.determineErrorCode(error);
|
|
224
264
|
const isCancellation = loggedErrorCode === JsonRpcErrorCode.RequestCancelled;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
265
|
+
/**
|
|
266
|
+
* A stack-free record has none of the stack fields `ErrorHandlerOptions.includeStack`
|
|
267
|
+
* lists, and writes every `Error` in it without its `stack` — whether this
|
|
268
|
+
* handler, the thrown `McpError`'s own `data`, the context, or `input`
|
|
269
|
+
* supplied it (#650). Any other key named `stack` is a caller's data and is
|
|
270
|
+
* written as given. The returned error is the same either way.
|
|
271
|
+
*/
|
|
272
|
+
const stackFree = !includeStack || isCancellation;
|
|
273
|
+
const errorDataSeed = readErrorData(error) ?? {};
|
|
228
274
|
/**
|
|
229
275
|
* `consolidatedData` becomes `McpError.data`, which the tool handler puts on
|
|
230
276
|
* `structuredContent.error.data`. It carries the thrown error's own data and
|
|
@@ -239,34 +285,58 @@ export class ErrorHandler {
|
|
|
239
285
|
originalMessage: originalErrorMessage,
|
|
240
286
|
};
|
|
241
287
|
/**
|
|
242
|
-
*
|
|
288
|
+
* What the cause chain says goes to the log record only, never into the
|
|
243
289
|
* returned error's `data`: `tryCatch` throws that error, and tools and
|
|
244
|
-
* resources forward an `McpError`'s `data` to the client verbatim (#519)
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
290
|
+
* resources forward an `McpError`'s `data` to the client verbatim (#519),
|
|
291
|
+
* so a message redacted at the throw site would reach the client raw
|
|
292
|
+
* through its cause (#644). A cancellation carries no chain — its every
|
|
293
|
+
* node would hold a stack and invite triage to read a caller hanging up
|
|
294
|
+
* as a fault in this server. `includeStack: false` keeps the chain, and
|
|
295
|
+
* the stack-free record logs none of its nodes' stacks (#586).
|
|
249
296
|
*/
|
|
250
297
|
const diagnostics = {};
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
!(error instanceof McpError && error.data?.originalStack)) {
|
|
254
|
-
diagnostics.originalStack = originalStack;
|
|
255
|
-
}
|
|
256
|
-
const cause = error instanceof Error ? error : undefined;
|
|
257
|
-
if (!isCancellation && error instanceof Error && error.cause) {
|
|
258
|
-
const causeChain = extractErrorCauseChain(error);
|
|
298
|
+
if (!isCancellation && thrownError && readField(thrownError, 'cause')) {
|
|
299
|
+
const causeChain = extractErrorCauseChain(thrownError);
|
|
259
300
|
const rootCause = causeChain.at(-1);
|
|
260
301
|
if (rootCause) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
302
|
+
diagnostics.rootCause = { name: rootCause.name, message: rootCause.message };
|
|
303
|
+
/**
|
|
304
|
+
* A node whose stack is the record's own, or the node's before it, is
|
|
305
|
+
* written without it — the rule the log walk applies to an `Error`'s
|
|
306
|
+
* `cause` — so the record carries each stack once (#694): the thrown
|
|
307
|
+
* error itself, and every error a nested `tryCatch` rebuilt from
|
|
308
|
+
* another. A stack that could not be read is no stack to repeat.
|
|
309
|
+
*/
|
|
310
|
+
diagnostics.causeChain = causeChain.map((node, i) => {
|
|
311
|
+
const { stack } = node;
|
|
312
|
+
const repeated = stack === originalStack || stack === causeChain[i - 1]?.stack;
|
|
313
|
+
if (stack === undefined || stack === UNREADABLE || !repeated)
|
|
314
|
+
return node;
|
|
315
|
+
const { stack: _stack, ...rest } = node;
|
|
316
|
+
return rest;
|
|
317
|
+
});
|
|
265
318
|
}
|
|
266
319
|
}
|
|
267
320
|
const finalError = errorMapper
|
|
268
321
|
? errorMapper(error)
|
|
269
|
-
: new McpError(loggedErrorCode, originalErrorMessage, consolidatedData, {
|
|
322
|
+
: new McpError(loggedErrorCode, originalErrorMessage, consolidatedData, {
|
|
323
|
+
cause: thrownError,
|
|
324
|
+
});
|
|
325
|
+
/**
|
|
326
|
+
* The rebuilt error takes the throw site's stack, so the error `tryCatch`
|
|
327
|
+
* rethrows starts where the failure happened rather than here (#694). It is
|
|
328
|
+
* copied verbatim: the header line names the class that was thrown, and
|
|
329
|
+
* `finalErrorType` on the record names the rebuilt one. A mapper's result
|
|
330
|
+
* keeps the stack its mapper gave it, and takes the throw site's only when
|
|
331
|
+
* it has none. A throw-site stack that could not be read is not copied.
|
|
332
|
+
*/
|
|
333
|
+
if (typeof originalStack === 'string' &&
|
|
334
|
+
originalStack &&
|
|
335
|
+
originalStack !== UNREADABLE &&
|
|
336
|
+
finalError !== error &&
|
|
337
|
+
(!errorMapper || !finalError.stack)) {
|
|
338
|
+
finalError.stack = originalStack;
|
|
339
|
+
}
|
|
270
340
|
/**
|
|
271
341
|
* Record error classification metric. The category is the same
|
|
272
342
|
* `getErrorCategory` answer the per-surface error counters carry, handed
|
|
@@ -281,47 +351,64 @@ export class ErrorHandler {
|
|
|
281
351
|
*/
|
|
282
352
|
getErrorMetrics().errorClassifiedCounter.add(1, {
|
|
283
353
|
[ATTR_MCP_ERROR_CLASSIFIED_CODE]: String(loggedErrorCode),
|
|
284
|
-
[ATTR_MCP_ERROR_CATEGORY]: getErrorCategory(loggedErrorCode,
|
|
354
|
+
[ATTR_MCP_ERROR_CATEGORY]: getErrorCategory(loggedErrorCode, errorDataSeed),
|
|
285
355
|
operation,
|
|
286
356
|
...(severity !== undefined && { [ATTR_MCP_ERROR_SEVERITY]: severity }),
|
|
287
357
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
358
|
+
/**
|
|
359
|
+
* The context is read once, through these copies: a field that throws when
|
|
360
|
+
* read — an own getter, a `Proxy` trap — would otherwise fail the call that
|
|
361
|
+
* reports a failure. A copy that throws is written as `'[Unreadable]'` in
|
|
362
|
+
* the record, under `context` or `extra`.
|
|
363
|
+
*/
|
|
364
|
+
const contextFields = copyFields(context);
|
|
365
|
+
const { extra: contextExtra, ...contextCanonical } = contextFields ?? {};
|
|
366
|
+
const extraFields = copyFields(contextExtra);
|
|
367
|
+
const logRequestId = typeof contextCanonical.requestId === 'string' && contextCanonical.requestId
|
|
368
|
+
? contextCanonical.requestId
|
|
297
369
|
: generateUUID();
|
|
298
|
-
const logTimestamp = typeof
|
|
299
|
-
?
|
|
370
|
+
const logTimestamp = typeof contextCanonical.timestamp === 'string' && contextCanonical.timestamp
|
|
371
|
+
? contextCanonical.timestamp
|
|
300
372
|
: new Date().toISOString();
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
373
|
+
/**
|
|
374
|
+
* Read and copied as the thrown value's is: an `errorMapper` may return the
|
|
375
|
+
* very error it was given. A `data` that cannot be read or copied gives way
|
|
376
|
+
* to `consolidatedData`.
|
|
377
|
+
*/
|
|
378
|
+
const errorData = { ...(readErrorData(finalError) ?? consolidatedData), ...diagnostics };
|
|
379
|
+
const handlerFields = {
|
|
380
|
+
critical,
|
|
381
|
+
errorCode: loggedErrorCode,
|
|
382
|
+
originalErrorType: originalErrorName,
|
|
383
|
+
finalErrorType: getErrorName(finalError),
|
|
384
|
+
errorData,
|
|
385
|
+
// The record's one stack: the throw site's, absent for a thrown value with none (#694).
|
|
386
|
+
...(originalStack ? { stack: originalStack } : {}),
|
|
387
|
+
};
|
|
388
|
+
// A context's `extra.stack` never stands in for the throw site's (#694).
|
|
389
|
+
const { stack: _contextStack, ...callerExtra } = extraFields ?? { extra: UNREADABLE };
|
|
390
|
+
/**
|
|
391
|
+
* The handler's own fields lead the record, so the log walk, which works
|
|
392
|
+
* in key order, reaches `errorData` before caller-sized `extra` and `input`
|
|
393
|
+
* can spend its bound on what it writes (#649); spread again last, so a
|
|
394
|
+
* caller's key never replaces one.
|
|
395
|
+
*/
|
|
396
|
+
const recordExtra = {
|
|
397
|
+
...handlerFields,
|
|
398
|
+
...callerExtra,
|
|
399
|
+
...(contextFields === undefined && { context: UNREADABLE }),
|
|
400
|
+
input: sanitizedInput,
|
|
401
|
+
...handlerFields,
|
|
305
402
|
};
|
|
306
|
-
const { extra: contextExtra = {}, ...contextCanonical } = context;
|
|
307
403
|
const logContext = {
|
|
308
404
|
operation,
|
|
309
405
|
...contextCanonical,
|
|
310
406
|
requestId: logRequestId,
|
|
311
407
|
timestamp: logTimestamp,
|
|
312
|
-
extra:
|
|
313
|
-
// `extra.stack` is the record's stack field, whoever set it.
|
|
314
|
-
...(includeStack ? contextExtra : withoutKey(contextExtra, 'stack')),
|
|
315
|
-
input: sanitizedInput,
|
|
316
|
-
critical,
|
|
317
|
-
errorCode: loggedErrorCode,
|
|
318
|
-
originalErrorType: originalErrorName,
|
|
319
|
-
finalErrorType: getErrorName(finalError),
|
|
320
|
-
errorData: includeStack ? errorData : withoutKey(errorData, 'originalStack'),
|
|
321
|
-
...(includeStack && stack && !isCancellation ? { stack } : {}),
|
|
322
|
-
},
|
|
408
|
+
extra: stackFree ? toStackFreeExtra(recordExtra) : recordExtra,
|
|
323
409
|
};
|
|
324
|
-
const
|
|
410
|
+
const finalMessage = readField(finalError, 'message');
|
|
411
|
+
const logDescription = finalMessage ? errorText(finalMessage) : originalErrorMessage;
|
|
325
412
|
if (isCancellation) {
|
|
326
413
|
logger.info(`Cancelled ${operation}: ${logDescription}`, logContext);
|
|
327
414
|
}
|
|
@@ -350,14 +437,17 @@ export class ErrorHandler {
|
|
|
350
437
|
* the full `issues` array so clients can render field-level errors).
|
|
351
438
|
*/
|
|
352
439
|
static classifyOnly(error) {
|
|
353
|
-
if (error
|
|
354
|
-
return {
|
|
440
|
+
if (isInstance(error, McpError)) {
|
|
441
|
+
return {
|
|
442
|
+
code: ErrorHandler.determineErrorCode(error),
|
|
443
|
+
message: errorText(readField(error, 'message')),
|
|
444
|
+
};
|
|
355
445
|
}
|
|
356
|
-
if (error
|
|
446
|
+
if (isInstance(error, ZodError)) {
|
|
357
447
|
return {
|
|
358
448
|
code: JsonRpcErrorCode.ValidationError,
|
|
359
449
|
message: getErrorMessage(error),
|
|
360
|
-
data: { issues: error
|
|
450
|
+
data: { issues: readField(error, 'issues') },
|
|
361
451
|
};
|
|
362
452
|
}
|
|
363
453
|
return {
|
|
@@ -403,15 +493,23 @@ export class ErrorHandler {
|
|
|
403
493
|
if (defaultFactory) {
|
|
404
494
|
return defaultFactory(error);
|
|
405
495
|
}
|
|
406
|
-
return
|
|
496
|
+
return asError(error);
|
|
407
497
|
}
|
|
408
498
|
/**
|
|
409
499
|
* Formats an error into a consistent `{ code, message, data }` structure for API responses or structured logging.
|
|
410
500
|
*
|
|
411
|
-
* - `McpError` → `{ code: error.code, message: error.message, data: error.data ?? {} }`
|
|
501
|
+
* - `McpError` → `{ code: error.code, message: error.message, data: <a copy of error.data> ?? {} }`
|
|
412
502
|
* - `Error` → `{ code: determineErrorCode(error), message: error.message, data: { errorType: error.name } }`
|
|
413
503
|
* - Other values → `{ code: JsonRpcErrorCode.UnknownError, message: getErrorMessage(value), data: { errorType: getErrorName(value) } }`
|
|
414
504
|
*
|
|
505
|
+
* Never throws on the value it formats: a `message` or `name` whose read throws is
|
|
506
|
+
* `'[Unreadable]'`, one that is not a string is written as text (`String` for a
|
|
507
|
+
* primitive, `'[Unreadable]'` for an object), a `data` that cannot be read or copied
|
|
508
|
+
* (a revoked `Proxy`) is `{}`, and a value `instanceof` cannot inspect (a revoked
|
|
509
|
+
* `Proxy`) is formatted as a non-Error. Every `data` field is one a response can
|
|
510
|
+
* carry: one `JSON.stringify` cannot write is `'[Unreadable]'`, and one that takes
|
|
511
|
+
* more than 1,000,000 JSON values to write is `'[Truncated]'`.
|
|
512
|
+
*
|
|
415
513
|
* @param error - The error instance or value to format.
|
|
416
514
|
* @returns A plain object with `code` (numeric `JsonRpcErrorCode`), `message` (string), and `data` (object).
|
|
417
515
|
*
|
|
@@ -425,18 +523,18 @@ export class ErrorHandler {
|
|
|
425
523
|
* ```
|
|
426
524
|
*/
|
|
427
525
|
static formatError(error) {
|
|
428
|
-
if (error
|
|
526
|
+
if (isInstance(error, McpError)) {
|
|
429
527
|
return {
|
|
430
|
-
code: error
|
|
431
|
-
message: error
|
|
432
|
-
data:
|
|
528
|
+
code: ErrorHandler.determineErrorCode(error),
|
|
529
|
+
message: errorText(readField(error, 'message')),
|
|
530
|
+
data: readWireErrorData(error) ?? {},
|
|
433
531
|
};
|
|
434
532
|
}
|
|
435
|
-
if (error
|
|
533
|
+
if (isInstance(error, Error)) {
|
|
436
534
|
return {
|
|
437
535
|
code: ErrorHandler.determineErrorCode(error),
|
|
438
|
-
message: error
|
|
439
|
-
data: { errorType: error
|
|
536
|
+
message: errorText(readField(error, 'message')),
|
|
537
|
+
data: { errorType: getErrorName(error) },
|
|
440
538
|
};
|
|
441
539
|
}
|
|
442
540
|
return {
|
|
@@ -454,9 +552,9 @@ export class ErrorHandler {
|
|
|
454
552
|
* error-handling boilerplate.
|
|
455
553
|
*
|
|
456
554
|
* The thrown error's `data` reaches the client when a tool or resource handler lets it propagate,
|
|
457
|
-
* so it carries the caught error's own `data`, `originalErrorName`, `originalMessage`,
|
|
458
|
-
*
|
|
459
|
-
* chain, and the context are logged (#548).
|
|
555
|
+
* so it carries the caught error's own `data`, `originalErrorName`, and `originalMessage`, but
|
|
556
|
+
* nothing derived from a cause, no stack, and nothing from `options.context`; the throw-site
|
|
557
|
+
* stack, `rootCause`, the cause chain, and the context are logged (#548, #644).
|
|
460
558
|
*
|
|
461
559
|
* @template T The expected return type of `fn`.
|
|
462
560
|
* @param fn - The function to execute. May be synchronous or return a `Promise`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../../../src/utils/internal/error-handler/errorHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,8BAA8B,EAC9B,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,IAAI,sBAAoE,CAAC;AAEzE,SAAS,eAAe;IACtB,sBAAsB,KAAK,aAAa,CACtC,uBAAuB,EACvB,gDAAgD,EAChD,UAAU,CACX,CAAC;IACF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AACpC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,gBAAgB;IAC9B,eAAe,EAAE,CAAC;AACpB,CAAC;AAED,iFAAiF;AACjF,SAA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ACH,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,WAAW,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE;gBACpD,GAAG,OAAO;gBACV,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;YACH,MAAM,OAAO,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../../../src/utils/internal/error-handler/errorHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACL,OAAO,EACP,UAAU,EACV,SAAS,EACT,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,UAAU,EACV,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,U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,CAAC,EAAE;SACzC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAC1B,EAAwB,EACxB,OAA6C;QAE7C,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,WAAW,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE;gBACpD,GAAG,OAAO;gBACV,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;YACH,MAAM,OAAO,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -3,7 +3,68 @@
|
|
|
3
3
|
* Enhanced with cause chain extraction and circular reference detection.
|
|
4
4
|
* @module src/utils/internal/error-handler/helpers
|
|
5
5
|
*/
|
|
6
|
+
import { type Span } from '@opentelemetry/api';
|
|
6
7
|
import { ZodError } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* What the error path writes for a field whose read throws — a getter, a
|
|
10
|
+
* `Proxy` trap, a revoked `Proxy` — as the log-data walk does.
|
|
11
|
+
*/
|
|
12
|
+
export declare const UNREADABLE = "[Unreadable]";
|
|
13
|
+
/** `value[key]`, or {@link UNREADABLE} when reading it throws. */
|
|
14
|
+
export declare function readField(value: object, key: PropertyKey): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* An error's `message` or `name`, as read, written as text: a string as it is;
|
|
17
|
+
* any other primitive as `String` converts it, which runs no caller code and
|
|
18
|
+
* never throws, a `Symbol` included (`'Symbol(description)'`), so a `message`
|
|
19
|
+
* set to `404` reads `'404'`; and an object or function as {@link UNREADABLE},
|
|
20
|
+
* since converting one runs its own `toString`, which can throw or return
|
|
21
|
+
* anything.
|
|
22
|
+
*/
|
|
23
|
+
export declare function errorText(value: unknown): string;
|
|
24
|
+
/**
|
|
25
|
+
* `value instanceof type`, or `false` when the check throws — a revoked
|
|
26
|
+
* `Proxy`, a `getPrototypeOf` trap — so such a value is handled as the
|
|
27
|
+
* non-instance it cannot be shown not to be.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isInstance<T>(value: unknown, type: abstract new (...args: never[]) => T): value is T;
|
|
30
|
+
/**
|
|
31
|
+
* A copy of `value`'s own enumerable fields, as a spread makes it (`{}` for
|
|
32
|
+
* `undefined`), or `undefined` when making it throws — a getter that throws, a
|
|
33
|
+
* `Proxy` whose trap throws.
|
|
34
|
+
*/
|
|
35
|
+
export declare function copyFields<T extends object>(value: T | undefined): T | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* A shallow copy of the `data` a thrown `McpError` carries, so the error path
|
|
38
|
+
* reads plain fields rather than the thrown value's. Nothing is serialized: the
|
|
39
|
+
* log record writes the copy through the bounded log walk, and the wire
|
|
40
|
+
* boundaries check it with {@link readWireErrorData}. `undefined` when `error`
|
|
41
|
+
* is not an `McpError`, carries no object `data`, or its `data` cannot be read
|
|
42
|
+
* or copied — a getter, a revoked `Proxy`, a throwing `ownKeys` trap.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readErrorData(error: unknown): Record<string, unknown> | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* {@link readErrorData} for a response: every field is one the wire carries.
|
|
47
|
+
* A field `JSON.stringify` cannot write is {@link UNREADABLE}, since a response
|
|
48
|
+
* holding one is never sent and the client waits for it, and a field that takes
|
|
49
|
+
* more than {@link WIRE_VALUES} JSON values to write is `'[Truncated]'`. Every
|
|
50
|
+
* other field is the thrown value itself, so readable `data` is sent byte for
|
|
51
|
+
* byte as thrown.
|
|
52
|
+
*/
|
|
53
|
+
export declare function readWireErrorData(error: unknown): Record<string, unknown> | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* `value` when it is an `Error`, else an `Error` whose message is `String(value)`
|
|
56
|
+
* — or {@link UNREADABLE} when the value can be neither checked nor converted
|
|
57
|
+
* (a revoked `Proxy`, a null-prototype object).
|
|
58
|
+
*/
|
|
59
|
+
export declare function asError(value: unknown): Error;
|
|
60
|
+
/**
|
|
61
|
+
* Marks `span` failed with `error`: records an `Error` as the span's exception,
|
|
62
|
+
* then sets the `ERROR` status with its `message` (any other value as `String`
|
|
63
|
+
* converts it). Never throws: an exception the span cannot read — a field
|
|
64
|
+
* whose getter throws, which the SDK's `recordException` reads unguarded — is
|
|
65
|
+
* left unrecorded, and a message that cannot be read is {@link UNREADABLE}.
|
|
66
|
+
*/
|
|
67
|
+
export declare function recordSpanFailure(span: Span, error: unknown): void;
|
|
7
68
|
/**
|
|
8
69
|
* Formats a ZodError as a single readable line: `<dotted.path>: <message>`.
|
|
9
70
|
*
|
|
@@ -26,11 +87,13 @@ export declare function formatZodErrorMessage(err: ZodError): string;
|
|
|
26
87
|
/**
|
|
27
88
|
* Retrieves a descriptive name for an error object or value.
|
|
28
89
|
*
|
|
29
|
-
* - `Error` instances → `error.name` (e.g. `'TypeError'`), falling back to `'Error'
|
|
90
|
+
* - `Error` instances → `error.name` (e.g. `'TypeError'`), falling back to `'Error'`;
|
|
91
|
+
* a `name` that is not a string is written as {@link errorText} writes it.
|
|
30
92
|
* - `null` → `'NullValueEncountered'`
|
|
31
93
|
* - `undefined` → `'UndefinedValueEncountered'`
|
|
32
94
|
* - Non-plain objects with a named constructor → `'<ConstructorName>Encountered'`
|
|
33
95
|
* - Everything else → `'<typeof value>Encountered'` (e.g. `'stringEncountered'`)
|
|
96
|
+
* - A value whose inspection throws (a `name` getter, a revoked `Proxy`) → `'[Unreadable]'`
|
|
34
97
|
*
|
|
35
98
|
* @param error - The error object or value.
|
|
36
99
|
* @returns A stable, human-readable string identifying the error's type.
|
|
@@ -47,13 +110,16 @@ export declare function getErrorName(error: unknown): string;
|
|
|
47
110
|
* Extracts a human-readable message string from any thrown value.
|
|
48
111
|
*
|
|
49
112
|
* Handles every JavaScript type so that `catch (e)` blocks never produce `[object Object]`:
|
|
50
|
-
* - `AggregateError` → combines up to 3 inner error messages after the outer message
|
|
51
|
-
*
|
|
113
|
+
* - `AggregateError` → combines up to 3 inner error messages after the outer message,
|
|
114
|
+
* each one that cannot be read as `'[Unreadable]'`.
|
|
115
|
+
* - `Error` → `error.message`, or `'[Unreadable]'` when reading it throws (a getter);
|
|
116
|
+
* a `message` that is not a string, the outer's or a member's, as {@link errorText} writes it.
|
|
52
117
|
* - `null` / `undefined` → descriptive literal strings.
|
|
53
118
|
* - Primitives (`string`, `number`, `boolean`, `bigint`, `symbol`) → string-coerced value.
|
|
54
119
|
* - Functions → `[function <name>]`
|
|
55
120
|
* - Objects → JSON-serialized if possible; otherwise constructor name fallback.
|
|
56
|
-
* -
|
|
121
|
+
* - A value whose inspection throws (a getter, a `Proxy` trap, a revoked `Proxy`) →
|
|
122
|
+
* `'[Unreadable]'`, never the text of what the read threw.
|
|
57
123
|
*
|
|
58
124
|
* @param error - The thrown value to extract a message from.
|
|
59
125
|
* @returns A non-empty string describing the error.
|
|
@@ -105,6 +171,11 @@ export interface ErrorCauseNode {
|
|
|
105
171
|
* `McpError` nodes include the `data` property when present, and any `Error`
|
|
106
172
|
* node carrying a string `code` includes it.
|
|
107
173
|
* Circular references are detected via `WeakSet` identity tracking.
|
|
174
|
+
* Every read is guarded: a `name`, `message`, or `stack` whose read throws is
|
|
175
|
+
* `'[Unreadable]'` on its node, an unreadable `code` or `data` is left out, and
|
|
176
|
+
* a cause that cannot be read or inspected — a throwing `cause` getter, a
|
|
177
|
+
* revoked `Proxy` — ends the chain as a node whose `name` and `message` are
|
|
178
|
+
* both `'[Unreadable]'`.
|
|
108
179
|
*
|
|
109
180
|
* @param error - The outermost error to start traversal from.
|
|
110
181
|
* @param maxDepth - Maximum number of nodes to traverse before stopping. Defaults to `20`.
|