import { Context , Get , Hook , HttpResponse , HttpResponseForbidden , isHttpResponseInternalServerError , renderError } from '@foal/core' ; class PermissionDenied extends Error { } export class AppController { @ Get ( '/products' ) @ Hook ( ( ) => response => { ( response as any ) . body += '!' ; } ) readProducts ( ) { throw new PermissionDenied ( 'Access forbidden' ) ; } handleError ( error , ctx ) { if ( error instanceof PermissionDenied ) { return new HttpResponseForbidden ( error . message ) ; } return renderError ( error , ctx ) ; } }