Search within TutorialsPark

AngularJS Services : Exceptions


Learn how to use AngularJS Exception services to handle exception arising during execution


AngularJS Services : Working with Exceptions

AngularJS service of $exceptionHandler is used to handle exception that may arise while the application is being executed.

In the demo, we use the service $exceptionHandler is used to write the details of the exception to the JavaScript console while the application continues to execute.

Example: AngularJS Service Working with Exception

Give it a TRY! » Note: See the last line of the console, which contains the Error and the cause of Error as defined in catch

AngularJS Service : Implementing a Custom Exception Handler

AngularJS allows you to define a custom exception handler by overriding the service of $errorHandler.

The demo uses the factory method to override the $errorHandler service object, thus creating a well formatted message.

Example: AngularJS Service Implementign a Custom Exception Handler

Give it a TRY! » Note:The Last line of the JavaScript console has the custom exception message.