Skip to content

Commit

Permalink
#664 change default category to "T" + add code to new WlsErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
vjohnslhm committed Dec 16, 2024
1 parent 70dd896 commit c272389
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion wls-gui-wahllokalsystem/src/api/WLSError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class WLSError extends Error {
constructor({
level = STATUS_INDICATORS.ERROR,
message = "Ein unbekannter Fehler ist aufgetreten, bitte den Administrator informieren.",
category = "undefined",
category = "T",
code = "undefined",
service = "undefined",
}: {
Expand Down
15 changes: 13 additions & 2 deletions wls-gui-wahllokalsystem/src/api/fetch-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ export function defaultResponseHandler(
level: STATUS_INDICATORS.ERROR,
message:
"Sie haben nicht die nötigen Rechte um diese Aktion durchzuführen.",
code: response.status.toString(),
});
} else if (response.type === "opaqueredirect") {
location.reload();
}
throw new WLSError({
level: STATUS_INDICATORS.WARNING,
message: errorMessage,
code: response.status.toString(),
});
}
}
Expand Down Expand Up @@ -131,6 +133,7 @@ export function wlsCatchHandler(response: Response): PromiseLike<never> {
throw new WLSError({
level: STATUS_INDICATORS.INFO,
message: "Es konnten keine Daten gefunden werden",
code: response.status.toString(),
});
}
if (response.status === 400) {
Expand All @@ -146,12 +149,20 @@ export function wlsCatchHandler(response: Response): PromiseLike<never> {
})
);
} else {
return Promise.reject(new WLSError({ message: "Error: Bad Request" }));
return Promise.reject(
new WLSError({
message: "Error: Ungültige Anfrage",
code: response.status.toString(),
})
);
}
});
} else {
return Promise.reject(
new WLSError({ message: "Ein unbekannter Fehler ist aufgetreten" })
new WLSError({
message: "Ein unbekannter Fehler ist aufgetreten",
code: response.status.toString(),
})
);
}
}
Expand Down

0 comments on commit c272389

Please sign in to comment.