Skip to main content

coded_error

Function coded_error 

Source
pub fn coded_error(class: &str, code: &str, msg: &str) -> String
Expand description

A Node coded error raised from the JS layer: Name [ERR_CODE]: message.

builtins::synth_error parses that head back apart, so the bracketed code becomes the enumerable err.code that err.code === 'ERR_INVALID_URL'-style handling reads. Writing the head by hand at each throw site is what left a dozen of them with err.code === undefined while the message matched.

Use this for errors Node raises from lib/internal/errors.js, whose .name is left bracketed while the stack is captured and therefore shows up in both String(err) and err.stack — measured on v26.7.0:

process.exit(1.5) -> RangeError [ERR_OUT_OF_RANGE]: The value of "code" …