safely.js

0.1.0 • Public • Published

Safely.js

safely(keepGoingIfThisFunctionFails)

Exceptions are rescued and automatically reported to your favorite reporting service.

In development and test environments, exceptions are raised so you can fix them.

Use It Everywhere

“Oh no, analytics brought down search”

safely(trackSearch)

Also aliases as yolo.

Installation

Download safely.js, include it, and set the environment

<script src="path/to/safely.js"></script>
<script>
  Safely.env = "production"
</script>

Reporting

Reports exceptions to Rollbar out of the box.

Customize reporting with:

Safely.reportExceptionMethod = function (e) {
  // report to your favorite service
}

By default, exception messages are prefixed with [safely]. This makes it easier to spot rescued exceptions. Turn this off with:

Safely.tag = false

To report exceptions manually:

Safely.reportException(e)

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

/safely.js/

    Package Sidebar

    Install

    npm i safely.js

    Weekly Downloads

    4

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • ankane