# Catching JSONAPIAdapter parse exception

**URL:** <https://discuss.emberjs.com/t/catching-jsonapiadapter-parse-exception/14258>\
**Category:** Ember Data\
**Created:** [February 16, 2018, 8:12pm UTC](https://discuss.emberjs.com/t/catching-jsonapiadapter-parse-exception/14258 "2018-02-16T20:12:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cah\_danmonroe](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/cah_danmonroe/32/13934_2.png) [@cah\_danmonroe](https://discuss.emberjs.com/u/cah_danmonroe)\
**Post date:** [February 16, 2018, 8:12pm UTC](https://discuss.emberjs.com/t/catching-jsonapiadapter-parse-exception/14258/1 "2018-02-16T20:12:22Z")

</div>

I’m trying to catch an error globally and trying to find the best place to do it. If we do any rest requests (saves, create, etc) and an error occurs on the backend, the backend we use redirects to a HTML “Oops” page. Now the response is straight HTML and our adapter doesn’t like it. It throws a

```
SyntaxError: Unexpected token < in JSON at position 0
    at parse (<anonymous>)
    at ajaxConvert (https://localhost:4200/cmr/assets/vendor.js:21239:19)
    at done (https://localhost:4200/cmr/assets/vendor.js:21707:15)
    at XMLHttpRequest.<anonymous> (https://localhost:4200/cmr/assets/vendor.js:22000:9)
    at FakeRequest.<anonymous> (https://localhost:4200/cmr/assets/vendor.js:78060:18)
    at FakeRequest.dispatchEvent (https://localhost:4200/cmr/assets/vendor.js:78104:24)
    at dispatchEvent (https://localhost:4200/cmr/assets/vendor.js:78656:17)
    at XMLHttpRequest.xhr.(anonymous function) (https://localhost:4200/cmr/assets/vendor.js:78666:9)

```

in the console. I’m trying to catch this in the JSONAPIAdapter with `handleResponse` but it blows up before it gets to it. Where can I catch this?

Thanks, Dan
