Installation is a breeze with npm (and no dependencies!):
$ npm install erroneous
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.
var Erroneous = ;// You can either initialize erroneous in this way (with an optional handler)Erroneous;// or this way:process;
The main object, that contains the logic for listening for errors and handling them.
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
callback is supplied, it will be called when the response
from the server has been received.
The object that the callback function receives (and the server, in JSON format)
ErroneousError. The object has several properties which, collected from
- 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 (
- target - A string that tries to describe the target of the error It can be an ID or a nodeName + classNames
- stack - The stacktrace