Skip to content

Commit 00b073d

Browse files
author
hirsch88
committed
Improve error handling
1 parent d2c6410 commit 00b073d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/api/middlewares/authenticate.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ export const authenticate = (request: RequestAPI<Request, Options, RequiredUriUr
4141

4242
// Catch auth0 exception and return it as it is
4343
log.warn(`Could not retrieve the user, because of`, body);
44-
res.failed(response.statusCode || 401, body);
44+
let statusCode = 401;
45+
if (response && response.statusCode) {
46+
statusCode = response.statusCode;
47+
} else {
48+
log.warn('It seems your oauth server is down!');
49+
}
50+
res.failed(statusCode, body);
4551

4652
});
4753

0 commit comments

Comments
 (0)