MCPcopy
hub / github.com/sindresorhus/got / wrapAssertionWithContext

Function wrapAssertionWithContext

source/core/options.ts:886–896  ·  view source on GitHub ↗

Generic helper that wraps any assertion function to add context to error messages.

(optionName: string, assertionFn: () => void)

Source from the content-addressed store, hash-verified

884Generic helper that wraps any assertion function to add context to error messages.
885*/
886function wrapAssertionWithContext(optionName: string, assertionFn: () => void): void {
887 try {
888 assertionFn();
889 } catch (error) {
890 if (error instanceof Error) {
891 error.message = `Option '${optionName}': ${error.message}`;
892 }
893
894 throw error;
895 }
896}
897
898/**
899Helper function that wraps assert.any() to provide better error messages.

Callers 2

assertAnyFunction · 0.85
assertPlainObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…