Exceptions implemented on top of pipelines. Exceptions can catch the method exception and transform the return value Exceptions must implement the IException interface.

if the exception decorate a class it will run on all class methods.



we create custom error filter and override the default error handling

import {exception,IException} from '@appolo/engine';
import {define} from '@appolo/inject';
export class CatchErrorPipe implements IPipe{
async catch(err:Error,context:PipelineContext){
let req = context.getRequest();
const statusCode = err instanceof HttpError
? err.statusCode
: 500;
return {
statusCode: statusCode,
timestamp: new Date().toISOString(),
path: req.url,
export const catchError = ()=> exception(CatchErrorPipe);

now lets use out date pipe

export class SomeController extends Controller{
public async getData(){
let data = await this.dataMagaer.getData()
return data