diff --git a/src/decorators/Page.ts b/src/decorators/Page.ts index 4e1a94c..b6c3c6d 100644 --- a/src/decorators/Page.ts +++ b/src/decorators/Page.ts @@ -157,8 +157,14 @@ export function Page(title: string, page: string, extraScripts: (string | { scri } catch(error) { console.error('[Page Decorator] Error:', error); - next(error); - return; + if(typeof next !== 'undefined') { + next(error); + return; + } + else { + // Because next is undefined and we still want to have Express handle the error we reject the promise + return Promise.reject(error); + } } } }