# Handling ValidationErrorResponses

**URL:** <https://discourse.aurelia.io/t/handling-validationerrorresponses/1484>\
**Category:** Help Requests\
**Created:** [August 2, 2018, 9:37am UTC](https://discourse.aurelia.io/t/handling-validationerrorresponses/1484 "2018-08-02T09:37:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SNO](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sno/32/650_2.png) [@SNO](https://discourse.aurelia.io/u/SNO)\
**Post date:** [August 2, 2018, 9:37am UTC](https://discourse.aurelia.io/t/handling-validationerrorresponses/1484/1 "2018-08-02T09:37:38Z")

</div>

Setting up a service using aurelia-fetch-client I have the following method:

```
public CreateEntity() : Promise<Entity>{
    return this.httpClient.fetch(route)
        .then(response => {
            if(response.ok && response.status == 200) return response.json();
        })
        .catch(err => {
            throw new Error("oh no. Something went wrong")
        })
}

```

Now the point is, that the API also returns validation-errors with status code of 400 and references to each invalid field.  
How can I interpret the 400 error message?

In my form I currently only get the object:

```
this.myService.CreateEntity().then(Entity => {
    this.entity = Entity;
})

```

**Update:**  
In beset case I would like to parse the error Response and work with aurelia-validation “addError”. Does anyone have an example?

---

<div class="post-metadata">

**Author:** ![davismj](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/davismj/32/267_2.png) [@davismj](https://discourse.aurelia.io/u/davismj)\
**Post date:** [August 3, 2018, 2:57am UTC](https://discourse.aurelia.io/t/handling-validationerrorresponses/1484/2 "2018-08-03T02:57:13Z")

</div>

> How can I interpret the 400 error message?

This is up to you. I recommend adding a variable on your view-model that has can hold the errors, logic in your view for viewing the errors, and then reading the errors in your `catch` and add them to the variable on your view model so that you can display them.

> In beset case I would like to parse the error Response and work with aurelia-validation “addError”. Does anyone have an example?

I don’t sorry. I personally tend to manually handle my errors rather than rely on aurelia-validation.
