
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
angular-errorz
Advanced tools
An error handling service for AngularJS
AngularJS ~1.2 is required
npm install angular-errorz
var exampleApp = angular.module("exampleApp", ["ttErrorz"]);
Configure the service within your app module's run block:
exampleApp.run(["errorz", function (errorz) {
errorz.addHandler(/* see Examples */);
}]);
addHandler(status, handler)
Add a handler for an HTTP status code
Param | Type | Details |
---|---|---|
status | Number | The HTTP status code to handle. |
handler | Function | The function the service should call when handling the specified HTTP status code. |
errorz
: for chaining.
addBatch(statuses, handler)
Add a handler for multiple HTTP status codes
Name | Type | Details |
---|---|---|
statuses | Array | The HTTP status codes to handle. |
handler | Function | The function the service should call when handling the specified HTTP status codes. |
errorz
: for chaining.
handled(status)
Determines whether the service has been configured to handle the specified status
Param | Type | Details |
---|---|---|
status | Number | The HTTP status code to check. |
Boolean
: true when the service contains a handler for the specified status.
statusCodes()
Gets the list of HTTP status codes the service has been configured to handle.
None
Array[String]
: an array of HTTP status codes.
Name | Type | Details |
---|---|---|
floodControl.threshold | Number | The number of milliseconds the service will wait before calling handlers for identical HTTP status codes. Setting this to undefined , null , or 0 will disable Flood Control. Defaults to 1000. |
Capture HTTP status code 500, and output the error to the browser's console.
errorz.addHandler(500, function (rejection) {
console.error("Please try again.", "Server Error 500");
});
Capture HTTP status codes: -1, 0, 500, using the same handler for all of them. Outputting the error to the browser's console.
errorz.addBatch([-1, 0, 500], function (rejection) {
console.error("Please try again.", "Server Error " + rejection.status);
});
You can do the same thing with multiple calls to addHandler
instead of addBatch
. Impractical, for this use case, but here it is for demonstrative purposes:
errorz.addHandler(-1, handler)
.addHandler(0, handler)
.addHandler(500, handler);
var handler = function (rejection) {
console.error("Please try again.", "Server Error " + rejection.status);
};
Similar to Example 2, but handle HTTP status code 404 conditionally within the same handler.
errorz.addBatch([-1, 0, 404, 500], function (rejection) {
rejection.status === 404 && console.warn(rejection.config.url, "404 Not Found")
|| console.error("Please try again.", "Server Error " + rejection.status);
});
Effectively the same end result as Example 3, just spread out.
errorz.addBatch([-1, 0, 500], function (rejection) {
console.error("Please try again.", "Server Error " + rejection.status);
});
Then, elsewhere/elsewhile...
errorz.addHandler(404, function(rejection) {
console.warn(rejection.config.url, "404 Not Found");
});
Same as Example 3, but notify the user with toastr instead of logging to the console. We also enable flood control with a threshold equal to toastr's timeout, to prevent spamming the user with toast when there is a flood of identical errors.
errorz.addBatch([-1, 0, 404, 500], function (rejection) {
rejection.status === 404 && toastr.warning(rejection.config.url, "404 Not Found")
|| toastr.error("Please try again.", "Server Error " + rejection.status);
}).floodControl.threshold = +toastr.options.timeOut;
FAQs
An error handling service for AngularJS
The npm package angular-errorz receives a total of 1 weekly downloads. As such, angular-errorz popularity was classified as not popular.
We found that angular-errorz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.