Open this example in the interactive library
Source code
const samples: unknown[] = [null, "Ada", 12, { id: 1 }, [2, 3], true];
console.log(
(() => {
try {
throw "offline";
} catch (reason: unknown) {
return reason instanceof Error ? reason.message : String(reason);
}
})(),
);
Sample output
offline
