MCPcopy
hub / github.com/cloudflare/vibesdk / processArgsWithError

Method processArgsWithError

worker/logger/core.ts:324–363  ·  view source on GitHub ↗

* Process arguments with error handling

(args: unknown[])

Source from the content-addressed store, hash-verified

322 * Process arguments with error handling
323 */
324 private processArgsWithError(args: unknown[]): {
325 data: Record<string, unknown>;
326 error?: Error;
327 } {
328 let error: Error | undefined;
329 const otherArgs: unknown[] = [];
330
331 const isErrorLike = (value: unknown): value is { name?: unknown; message?: unknown; stack?: unknown } => {
332 return (
333 value !== null &&
334 typeof value === 'object' &&
335 ('message' in (value as Record<string, unknown>) || 'name' in (value as Record<string, unknown>))
336 );
337 };
338
339 const toError = (value: { name?: unknown; message?: unknown; stack?: unknown }): Error => {
340 const msg = typeof value.message === 'string' ? value.message : 'Unknown error';
341 const err = new Error(msg);
342 if (typeof value.name === 'string') err.name = value.name;
343 if (typeof value.stack === 'string') (err as Error).stack = value.stack;
344 return err;
345 };
346
347 args.forEach((arg) => {
348 if (arg instanceof Error) {
349 error = arg;
350 return;
351 }
352 if (isErrorLike(arg)) {
353 error = toError(arg);
354 return;
355 }
356 otherArgs.push(arg);
357 });
358
359 return {
360 data: this.processArgs(otherArgs),
361 error,
362 };
363 }
364
365 // Public logging methods
366 debug(message: string, ...args: unknown[]): void {

Callers 1

errorMethod · 0.95

Calls 2

processArgsMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected