https://github.com/bootstarted/bugnet
Capture Javascript errors.
https://github.com/bootstarted/bugnet
bootstart error-handling metalab
Last synced: 8 months ago
JSON representation
Capture Javascript errors.
- Host: GitHub
- URL: https://github.com/bootstarted/bugnet
- Owner: bootstarted
- Created: 2016-08-15T21:44:01.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-06T19:51:31.000Z (almost 8 years ago)
- Last Synced: 2025-05-31T03:50:52.521Z (8 months ago)
- Topics: bootstart, error-handling, metalab
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bugnet
Capture Javascript errors. Minimal version of [rollbar], [bugsnag], etc.





## Usage
Simply pass the function you wish to use for being notified of errors. As soon as you include `bugnet` in your application errors will start to be captured and buffered until they're ready to be consumed later. It is recommended you include `bugnet` as soon as possible in your application.
Importantly `bugnet` will **NOT** squelch your application errors (i.e. not a silent `catch`-all) - it simply monitors them.
```sh
npm install --save bugnet
```
```javascript
import capture from 'bugnet';
capture((error) => {
// ...
});
```
### Examples
#### Browser
Send browser errors to an off-site logger:
```javascript
import capture from 'bugnet';
// Add event handler.
capture((error) => {
const request = new XMLHttpRequest();
request.open('http://errors.myapp.com/', 'POST', true);
request.send(JSON.stringify(event));
});
```
#### Node
Send node.js errors to the console:
```javascript
// example.js
import capture from 'bugnet';
// Add event handler.
capture((error) => {
console.log('Got error', error);
});
```
To start capturing errors at the earliest possible point, load `bugnet` from `node` itself.
```sh
#!/bin/sh
node -r bugnet ./example.js
```
## TODO:
* Testing
* Fix incompatibilities using `Object.*` methods
[rollbar]: https://rollbar.com/
[bugsnag]: https://bugsnag.com/