ember-ajax icon indicating copy to clipboard operation
ember-ajax copied to clipboard

How to use error handler helpers in glimmer version?

Open SandeepJoel opened this issue 2 years ago • 1 comments

import { redirectToLogin } from 'new-frontend/utils/route-helpers';
import { UnauthorizedError } from 'ember-ajax/errors';

function commonErrorHandler(error) {
  if (UnauthorizedError(error)) {
    redirectToLogin.call(this);
  }
}

export { commonErrorHandler };

I have this function in utility. Whenever I call the function commonErrorHandler, I'm getting the following error.

Screenshot 2022-07-02 at 1 55 52 PM Screenshot 2022-07-02 at 1 56 00 PM

SandeepJoel avatar Jul 02 '22 08:07 SandeepJoel

https://github.com/ember-cli/ember-ajax/blob/5520bdf3561175f0a6b5827cd0c2d4b36dd2ef4f/addon/errors.ts#L19-L23

Those seem to be proper classes now, so you'd have to either instance check them or if you are creating one, use new. It seems like you are wanting to do an "instanceOf" but maybe i'm miss understanding.

webark avatar Jul 02 '22 13:07 webark