From 203d0488e62e2ce1f12ac39559cceea5d60c654c Mon Sep 17 00:00:00 2001 From: Alan Bridgeman Date: Tue, 24 Jun 2025 11:42:01 -0500 Subject: [PATCH] Because for async contexts the ext function still seems to be undefined within the #Page decorator we just reject the Promise instead hoping this will tigger the proper express Error handling --- src/decorators/Page.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/decorators/Page.ts b/src/decorators/Page.ts index fc3a34b..4e1a94c 100644 --- a/src/decorators/Page.ts +++ b/src/decorators/Page.ts @@ -98,8 +98,15 @@ 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); + } } } }