Backend geeft nu een 401 ipv. een 500 terug voor de 'expired jwt' fout
This commit is contained in:
parent
61c751c343
commit
c2f3a6169a
7 changed files with 132 additions and 5 deletions
|
@ -1,7 +1,9 @@
|
|||
import { HasStatusCode } from "./has-status-code";
|
||||
|
||||
/**
|
||||
* Exceptions which are associated with a HTTP error code.
|
||||
*/
|
||||
export abstract class ExceptionWithHttpState extends Error {
|
||||
export abstract class ExceptionWithHttpState extends Error implements HasStatusCode {
|
||||
constructor(
|
||||
public status: number,
|
||||
public error: string
|
||||
|
|
6
backend/src/exceptions/has-status-code.ts
Normal file
6
backend/src/exceptions/has-status-code.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export interface HasStatusCode {
|
||||
status: number
|
||||
}
|
||||
export function hasStatusCode(err: unknown): err is HasStatusCode {
|
||||
return typeof err === 'object' && err !== null && 'status' in err && typeof (err as HasStatusCode)?.status === 'number';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue