Skip to main content

plain_coded_error

Function plain_coded_error 

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

A Node coded error raised from the native layer: .code is set, but the name is never bracketed, so String(err) is the plain Name: message.

The distinction is observable and is not a stylistic choice — on v26.7.0, String(new URL("/x") error) is TypeError: Invalid URL with .code === 'ERR_INVALID_URL', while the JS-layer process.exit(1.5) error brackets its code into the very same two reads. Encoding both through one Name [CODE]: head would have to pick one and be wrong about the other.

The code rides in a marker at the head of the message rather than in the error class, because the class text is exactly what must NOT carry it. The marker is an internal wire format between a throw site and synth_error; it never survives into a .message.