Socket
Socket
Sign inDemoInstall

serialised-error

Package Overview
Dependencies
3
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    serialised-error

Serialises error object to normal object


Version published
Weekly downloads
565K
increased by1.15%
Maintainers
3
Install size
382 kB
Created
Weekly downloads
 

Readme

Source

Serialised Error

This module attempts to convert an error object into a regular JavaScript object. This is useful if an error object has to be stored and operated upon.

Usage

var SerialisedError = require('serialised-error');

// assuming you have an error
var someError = new Error("This is a test error");

// convert the error to object (new operator is optional)
var serialisedError = new SerialisedError(someError);

// convert the serialised error to JSON
console.log(JSON.parse(serialisedError));

// this outputs:
// {"name": "Error", "message": "This is a test error", "stack": "Error\n   at ..."}

Adding additional meta information to error

Passing a second argument as true to the SerialisedError constructor adds the following keys to the serialised object.

PropertyDescription
checksuma SHA1 checksum of the error that is constant for same name, message and stack
ida random UUID (v4) of the error
timestampthe time when the error was serialised
timestampISOthe time (in ISO format) when the error was serialised
stacktracea prettified array of stack traces

Installation

npm install serialised-error;

Keywords

FAQs

Last updated on 07 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc