@Catch - error handling
Easy way to handle errors thrown from a metho
Overview
The @Catch()
decorator provides an easy way to handle errors thrown from any method.
Also, it's provide a way to handle errors based on type
The @Catch decorator can be applied on class level or method level
Usage
The Catch decorator can be use with error types or without declaring on error types
Catch(handler: (err: Error | SugoiError) => any)
Catch(handler: (err: Error | SugoiError) => any, ...errors: Array<string |Error | SugoiError>)
Catch all errors
Declaring error type
While declaring an error type only error types of those type will be handled by the handler method
Example
Last updated