Skip to content

Commit ea780cb

Browse files
authored
Update error message for unexpected NUS auth errors (#3836)
* Update error message for unexpected auth errors * Ingore unused var for build error due to nested function * Ignore unused error variable in nested function
1 parent 248e471 commit ea780cb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

website/api/nus/auth/login.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { authenticate } from '../../../src/serverless/nus-auth';
22
import {
33
createRouteHandler,
44
defaultFallback,
5-
defaultRescue,
65
Handler,
76
MethodHandlers,
87
} from '../../../src/serverless/handler';
@@ -33,8 +32,17 @@ const handlePost: Handler = async (req, res) => {
3332
}
3433
};
3534

35+
// eslint-disable-next-line no-unused-vars
36+
const handleError: (error: Error) => Handler = (error) => async (_req, res) => {
37+
res.status(500).json({
38+
message:
39+
'An unexpected error occurred. Please try clearing your browser cache and logging in again. Follow the NUS login page instructions carefully.',
40+
error,
41+
});
42+
};
43+
3644
const methodHandlers: MethodHandlers = {
3745
POST: handlePost,
3846
};
3947

40-
export default createRouteHandler(methodHandlers, defaultFallback, defaultRescue(true));
48+
export default createRouteHandler(methodHandlers, defaultFallback, handleError);

0 commit comments

Comments
 (0)