New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

erroneous

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

erroneous

JavaScript exception-handling for both client side and Node.js scripts

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Erroneous

JavaScript exception-handling for both client side and Node.js scripts

Installation

Installation is a breeze with npm (and no dependencies!):

$ npm install erroneous

Usage

In browser-context Erroneous subscribes itself to the error event of the window object. Thus there's only the handling of the errors left. In Node.js you'll need to call Erroneous.error yourself - This is to provide a greater degree of freedom in your code.

Node.js:

var Erroneous = require('erroneous');

// You can either initialize erroneous in this way (with an optional handler)
Erroneous.listen().register(function(err) {
  console.log('Custom error handler..', err);
});

// or this way:
process.on('uncaughtException', function(e) {
  Erroneous.error(e);
});

Browser:

<script src='./lib/erroneous.js'></script>
<script>
  // Send error to server for logging
  Erroneous.server('https://example.com/log');

  // Register a custom error handler
  Erroneous.register(function(err) {
    console.log('Custom error handler..', err);
  });
</script>

API

Erroneous

The main object, that contains the logic for listening for errors and handling them.

Erroneous.register(Function callback)

Registers a callback, that is called when an error occurs

Erroneous.server(String serverURL, [Function callback])

Register an internal callback that sends the error to the server in JSON format. If callback is supplied, it will be called when the response from the server has been received.

ErroneousError

The object that the callback function receives (and the server, in JSON format) is an ErroneousError. The object has several properties which, collected from the Error event.

  • line - The linenumber
  • file - The filename of the file where the error occured
  • msg - The raw error message, received from the browser
  • time - A timestamp of the date when the error occured
  • type - The type of error occured (SyntaxError, ReferenceError etc.)
  • target - A string that tries to describe the target of the error It can be an ID or a nodeName + classNames
  • stack - The stacktrace

Keywords

FAQs

Package last updated on 01 Sep 2012

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc