Display error message from backend to end user in interface

I have a general design-based question regarding the display of an error message with a subsequent backend to the end user in the interface. Not sure where to look for it. Thus, the answer to the error will be something like this.

Error Status: 400 (Bad Request)
{
    value: "+++",
    errorMessage: value "+++" fails to match alpha numeric pattern

}

Now in the interface I do not want to show the message directly from the backend. Since it may be of a technical nature (I would write this error message from the backend). I want to show the best user-friendly message.

"Invalid entry '+++' Numbers and texts are only allowed."

My question is how to do this. One way I could think of is to return a type of error in response. Then I will check the type of error in the interface, and then display the message on the front side accordingly. So my answer from the backend would be something like this

Error Status: 400 (Bad Request)
{
    value: "+++",
    errorMessage: value "++++" fails to match alpha numeric pattern
    errorType: INVALID_PATTERN
}

ENUM,

ERROR_TYPES: [
{
    INVALID_PATTERN: "Invalid entry <variable> Numbers and texts are only allowed."
}]

? - ?

, , .

P.S. MEAN

+4

Source: https://habr.com/ru/post/1678366/


All Articles