# How to handle Ember.Data model errors

**URL:** <https://discuss.emberjs.com/t/how-to-handle-ember-data-model-errors/13380>\
**Category:** Uncategorized\
**Created:** [August 2, 2017, 8:11am UTC](https://discuss.emberjs.com/t/how-to-handle-ember-data-model-errors/13380 "2017-08-02T08:11:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rzky](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rzky/32/13196_2.png) [@rzky](https://discuss.emberjs.com/u/rzky)\
**Post date:** [August 2, 2017, 8:11am UTC](https://discuss.emberjs.com/t/how-to-handle-ember-data-model-errors/13380/1 "2017-08-02T08:11:35Z")

</div>

Silly question. I have this action that captures model loading error, which sets a property that toggles an error message on the template.

```javascript
// route/parenting.js
actions: {
  error(error, transition) {
    let errors = error.payload.errors[0];
    if (errors.status === 404) {
      this.set('controller.errorMessage', 'No content found');
    }
  }
}

```

So now i need to make the message go away when the request is a success. Where do i reset the `controller.errorMessage` property state? Doing it from the model `then` block like this gives me an error:

```javascript
// route/parenting.js
model(params) {
  return RSVP.hash({
    ...

    // using ember-infinity
    articles: this.infinityModel('article', {
      perPage: 4,
      startingPage: 1,
      modelPath: 'controller.model.articles'
    }).then((res) => {
      // doing this throws an error:
      // Cannot read property 'errors' of undefined
      this.set('controller.errorMessage', false);
      return res;
    })
  })
}

```

I’m not sure this is the correct way to handle errors. But i’ve never manage to make Ember’s built-in `error` or `article.error` route to work.
