Catching JSONAPIAdapter parse exception


#1

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