The CoercionError is thrown when a value associated with a key cannot be coerced into a another type.
CoercionError
This error helps enforce type safety in parsers by signaling when the value is not a valid value of the target type.
throw new Parser.CoercionError("age", "number");// Error: Key "age" could not be coerced to number Copy
throw new Parser.CoercionError("age", "number");// Error: Key "age" could not be coerced to number
Optional
Static
Optional override for formatting stack traces
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Create .stack property on a target object
The
CoercionError
is thrown when a value associated with a key cannot be coerced into a another type.This error helps enforce type safety in parsers by signaling when the value is not a valid value of the target type.
Example