https://github.com/robinbuschmann/angular-filtered-catch
angular-filtered-catch is an extension for angulars promise implementation, which adds the possibility to filter catches by a specified error type.
https://github.com/robinbuschmann/angular-filtered-catch
Last synced: 11 months ago
JSON representation
angular-filtered-catch is an extension for angulars promise implementation, which adds the possibility to filter catches by a specified error type.
- Host: GitHub
- URL: https://github.com/robinbuschmann/angular-filtered-catch
- Owner: RobinBuschmann
- Created: 2016-06-19T17:10:11.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-22T11:18:03.000Z (almost 10 years ago)
- Last Synced: 2025-03-25T19:48:59.757Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angular-filtered-catch
This project is an extension for angulars promise implementation, which adds the possibility to filter catches by a specified error type.
## Usage
Add _angular-filtered-catch_ as dependency in your project.
````
angular.module('your-ng-app', ['angular-filtered-catch']);
````
````
// your specific error implementation
class FooError extends Error {}
// somewhere in your code
$q
.when()
.then(() => {
// ...
throw new FooError();
})
.then(() => {
// never executed
})
.catch(FooError, err => {
// handle FooError
})
.catch(err => {
// handle all other errors
})
````
## TypeScript support
This project also contains of a typescript declaration file, which extends angulars IPromise interface.