1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-22 14:44:21 +00:00

Handle unexpected API errors

This commit is contained in:
Steffo 2022-07-17 19:53:16 +02:00
parent 94e31d361b
commit f5a58188cc
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -65,7 +65,7 @@ export class Response {
* @param defaultMessage - The message to display if the server is running in production mode and cannot display full error messages or if the error message cannot be determined.
*/
static fromUnknownError(obj: unknown, defaultMessage: string = "Unexpected server error occurred") {
if (process.env.NODE_ENV === "development") {
if (process.env.NODE_ENV !== "development") {
return this.error({ message: defaultMessage })
}
@ -141,7 +141,7 @@ export class Response {
e.consume(res)
}
else {
throw e
this.fromUnknownError(e).consume(res)
}
}
}