Error Handling (UI) - SingletonTheory/SingletonTheory.github.io GitHub Wiki

Error Handling (UI)

Description

This page defines the way we handle errors in Singleton Theory. The outcomes of this should be a simple solution that is reusable across the application.

Implementation

Exception Service

The $exceptionHandler from angular is overwritten in the ExceptionService.js file. This listens for all thrown errors and will handle the errors according to types as defined below.

This implementation is dependent on the utilitiesService to be injected into the areas where Error Handling occurs.

Throwing Known Errors

To throw an known error in the application do as follows:

throw utilitiesService.createKnownException(<<ErrorType>>, 'Error detected. Please contact the system administrator.', 'STACK : Error detected. Please contact the system administrator.');

Throwing Un-Known Errors

To throw an un-known error just throw normally the exception handler will catch it and log to the console.

Error Types

The known error types are defined as follows:

  • Info
  • KnownError

Setting Known Errors

To set an error without throwing it in the application do as follows:

utilitiesService.setKnownException($rootScope, "The item already exist in the database!!");
⚠️ **GitHub.com Fallback** ⚠️