Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

How to use error handler helpers in glimmer version? #468

Open
SandeepJoel opened this issue Jul 2, 2022 · 1 comment
Open

How to use error handler helpers in glimmer version? #468

SandeepJoel opened this issue Jul 2, 2022 · 1 comment

Comments

@SandeepJoel
Copy link

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

@webark
Copy link
Contributor

webark commented Jul 2, 2022

export class UnauthorizedError extends AjaxError {
constructor(payload: any) {
super(payload, 'Ajax authorization failed', 401);
}
}

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants