---
# System prepended metadata

title: Error handling Options
tags: [client-archief]

---

---
tags : client-archief
---

# Error handling Options
Research a few options of error handling

### ErrorEnum per Action
Every action should have its own Enum type that contains the possible errors (with strings) for that action. Extending from Enum values "Timeout" and "No Error".

A different option could be to have a big enum with all the errors and explicitly limit the error enums in the response or error objects. 

## Errors in Response object
The case where there is an error attribute in the response object is the easiest case. The error type can be checked by TypeScript. The client just checks whether the error is active. If not, use the other attributes of the response object.

## Error class
Create an error class that can hold one of the ErrorEnum types. The promise can then be rejected or use a throw statement and .catch() handler.

## Pass string error from server
A final possibility is to let the server generate an error message for us, we can then throw an error or reject the promise with the given message. The message should then be shown to the user of the client.