UNPKG

knowhow-server

Version:

A personal workflow engine that can manage and use any network connected host

35 lines (34 loc) 2.4 kB
<a href="http://github.com/angular/angular.js/tree/v1.2.9/src/ng/exceptionHandler.js#L3" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ng/exceptionHandler.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">$exceptionHandler</code> <div><span class="hint">service in module <code ng:non-bindable="">ng</code> </span> </div> </h1> <div><h2 id="description">Description</h2> <div class="description"><div class="ng-exceptionhandler-page"><p>Any uncaught exception in angular expressions is delegated to this service. The default implementation simply delegates to <code>$log.error</code> which logs it into the browser console.</p> <p>In unit tests, if <code>angular-mocks.js</code> is loaded, this service is overridden by <a href="api/ngMock.$exceptionHandler">mock $exceptionHandler</a> which aids in testing.</p> <h4 id="description_example">Example:</h4> <pre class="prettyprint linenums"> angular.module('exceptionOverride', []).factory('$exceptionHandler', function () { return function (exception, cause) { exception.message += ' (caused by "' + cause + '")'; throw exception; }; }); </pre> <p>This example will override the normal action of <code>$exceptionHandler</code>, to make angular exceptions fail hard when they happen, instead of just logging to the console.</p> </div></div> <h2 id="dependencies">Dependencies</h2> <ul class="dependencies"><li><code ng:non-bindable=""><a href="api/ng.$log">$log</a></code> </li> </ul> <h2 id="usage">Usage</h2> <div class="usage"><pre class="prettyprint linenums">$exceptionHandler(exception[, cause]);</pre> <h4 id="usage_parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>exception</td><td><a href="" class="label type-hint type-hint-error">Error</a></td><td><div class="ng-exceptionhandler-page"><p>Exception associated with the error.</p> </div></td></tr><tr><td>cause <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ng-exceptionhandler-page"><p>optional information about the context in which the error was thrown.</p> </div></td></tr></tbody></table></div> </div>