Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: serialize-error
node v16.18.0
endpoint
share
tweet
const {serializeError, deserializeError} = require('serialize-error'); class MyError extends Error { constructor(message) { super(message); this.name = 'MyError' } } const original = new MyError('This is my error'); const serialized = serializeError(original); const deserialized = deserializeError(serialized); console.log('original', original instanceof MyError ? 'is MyError' : 'is not MyError') console.log('deserialized', deserialized instanceof MyError ? 'is MyError' : 'is not MyError') console.log('deserialized.name', deserialized.name)
Created from: https://npm.runkit.com/serialize-error
Loading…
Clone and edit this document