Sometimes we need to find out which error was thrown. To avoid a break of our application when we change the string of the error message, we should use constants that we use for throwing an error and that can be used by a developper for checking it like
const STATUS_NOT_VALID = "Status is not valid";
...
throw new Error(STATUS_NOT_VALID)
...
catch(e) {
if(e.message === STATUS_NOT_VALID)
}
Sometimes we need to find out which error was thrown. To avoid a break of our application when we change the string of the error message, we should use constants that we use for throwing an error and that can be used by a developper for checking it like