/** * Rendering an unknown throw as text. * * `catch (err)` binds `unknown`: JavaScript lets any value be thrown, and the DNS resolver, a * lexicon parser, or a stranger's `dist/data.js` may throw a string as readily as an `Error`. * Every place that puts a caught value into a message needs the same two-line dance, so it * lives here once. * * This module is a leaf that imports nothing, and it belongs to no subsystem: `src/build/**`, * `src/verify/**`, and `bin/**` all reach it without any of them depending on each other. * `src/serve/**`, `src/worker/**`, and `src/node/**` do not use it — see docs/INTERFACES.md. */ /** * @param {unknown} err * @returns {string} `err.message` for an `Error`, and `String(err)` for anything else */ export function message(err) { return err instanceof Error ? err.message : String(err) }