RunKit + npm: serialize-error

node v16.18.0
endpointsharetweet
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…