diff --git a/public/locales_euid/en.json b/public/locales_euid/en.json index cab02a8..5281c30 100644 --- a/public/locales_euid/en.json +++ b/public/locales_euid/en.json @@ -19,6 +19,8 @@ "Enter your verification code": "Enter your verification code", "Powered by": "Powered by", "Internal Server Error": "Internal Server Error", + "Page Not Found": "Page Not Found", + "Unknown Error": "Unknown Error", "euid-exit": "EXIT", "Welcome!": "Hello,", "Opt-Out": "Opt-Out", diff --git a/public/locales_uid2/en.json b/public/locales_uid2/en.json index 3b7271a..0b469f0 100644 --- a/public/locales_uid2/en.json +++ b/public/locales_uid2/en.json @@ -16,6 +16,8 @@ "Enter your verification code": "Enter your verification code", "Powered by": "Powered by", "Internal Server Error": "Internal Server Error", + "Page Not Found": "Page Not Found", + "Unknown Error": "Unknown Error", "EXIT": "EXIT", "Welcome!": "Hello,", "Opt-Out": "Opt-Out", diff --git a/public/locales_uid2/ja.json b/public/locales_uid2/ja.json index bf3701e..41d8074 100644 --- a/public/locales_uid2/ja.json +++ b/public/locales_uid2/ja.json @@ -16,6 +16,8 @@ "Enter your verification code": "認証コードを入力してください", "Powered by": "Powered by", "Internal Server Error": "内部サーバーエラー", + "Page Not Found": "ページが見つかりません", + "Unknown Error": "不明なエラー", "EXIT": "終了", "Welcome!": "こんにちは", "Opt-Out": "オプトアウト", diff --git a/src/app.ts b/src/app.ts index 0f43de0..d961e14 100644 --- a/src/app.ts +++ b/src/app.ts @@ -75,7 +75,17 @@ app.use((err: any, req: Request, res: Response, _next: NextFunction) => { // render the error page res.status(err.status || 500); - res.render('error'); + + let errorPageMessage; + if (err.status === 404) { + errorPageMessage = res.__('Page Not Found'); + } else if (err.status === 500) { + errorPageMessage = res.__('Internal Server Error'); + } else { + errorPageMessage = res.__('Unknown Error'); + } + + res.render('error', { errorPageMessage }); }); logger.log('info', `Using locales from ${LOCALE_FOLDER}`); diff --git a/src/routes/index.ts b/src/routes/index.ts index 0a039b6..76279e5 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -59,7 +59,7 @@ const handleEmailPromptSubmission: RequestHandler<{}, z.infer{{__ "Internal Server Error"}} \ No newline at end of file +

{{errorPageMessage}}

diff --git a/views_uid2/error.hbs b/views_uid2/error.hbs index e9910bb..5a6022e 100644 --- a/views_uid2/error.hbs +++ b/views_uid2/error.hbs @@ -1 +1 @@ -

{{__ "Internal Server Error"}}

\ No newline at end of file +

{{errorPageMessage}}