mm-angular-exception-handler

An angular module that override default $exceptionHandler service.


Keywords
exception, error, $exceptionHandler, angular, angularjs
License
MIT
Install
bower install mm-angular-exception-handler

Documentation

Bower version Build Status Coverage Status

mm-angular-exception-handler

The mm.exceptionHandler module override Angular's default $exceptionHandler, it preserves the default behaviour (logging to the console by mm.logger but also posts the error to Sentry or some custom reporting tool.

Requirements: AngularJS 1.2+, mm-angular-logger 0.3+

File Size: 14.36Kb minified, 893b gzipped

Install

Install via bower:

$ bower install mm-angular-exception-handler

Inject the mm.exceptionHandler module into your app:

var app = angular.module('ExceptionDemo', [
    'mm.exceptionHandler'
]);

Configuration

By default posting error to reporting tool is turn off. This can be turn on by configuring the $exceptionHandlerProvider.

Custom reporting tool:

It's up to you to provide your own back end implementation that accept post json request. Have look for simple example in demo and gulp serve task.

app.config(['$exceptionHandlerProvider', function (cfg) {
    cfg.setConfigAppErrorPrefix('demoApp'); // optional
    cfg.setConfigCustomDns('http://localhost:3000/error');
}]);

Sentry reporting tool:

You need to create Sentry account to be able to send error data to Sentry.

<script src="//cdn.ravenjs.com/1.1.15/raven.min.js"></script>
app.config(['$exceptionHandlerProvider', function (cfg) {
    var ravenConfig = {logger: 'javascript'};
    cfg.setConfigAppErrorPrefix('demoApp'); // optional
    cfg.setConfigRavenDns('https://7be.......491@app.getsentry.com/2...2');
    cfg.setConfigRavenConfig(ravenConfig); // optional
}]);

Developers

Clone the repo, git clone git://github.com/martinmicunda/mm-angular-exception-handler.git.

The mm-angular-exception-handler is tested with karma against the latest stable release of AngularJS.

$ npm install
$ gulp test

You can build the latest version using gulp.

$ gulp build

You can quickly hack around with:

$ gulp serve

Release

During the release process only dist, package.json, bower.json and CHANGELOG.md files should be edited and all steps should be done with gulp tasks and not manually!

  • To push a new release:
    1. Update package.json and bower.json version to new version with gulp bump --type=(major|minor|patch)
    2. Build dist files with gulp build
    3. Generate changelog with gulp changelog
    4. Go through the changelog, and fix any mistakes or clarify any unclear commit messages
    5. Commit and push dist, package.json, bower.json and CHANGELOG.md with gulp release

Versioning

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major (and resets the minor and patch)
  • New additions without breaking backward compatibility bumps the minor (and resets the patch)
  • Bug fixes and misc changes bumps the patch

For more information on SemVer, please visit http://semver.org/.

Contributing

Please submit all pull requests the against master branch. If your code contains JavaScript patches or features, you should include relevant unit tests. See CONTRIBUTING file more details. Thanks!

License

The MIT License

Copyright (c) 2014 Martin Micunda  

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.