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

Create base Error class for HTTP errors

Open sandstrom opened this issue 8 years ago • 5 comments

It would be useful with an isHttpError(myError) function, which would essentially be everything that isn't timeout or aborted. Would you be open to adding something like that?

sandstrom avatar Apr 25 '17 14:04 sandstrom

Yeah, I don't see a problem there. Is a 'timeout' really not an HTTP error? Honest question, I don't know the answer to that. I totally see how 'aborted' would not be one.

alexlafroscia avatar Apr 25 '17 19:04 alexlafroscia

It's not an HTTP error in the sense that there is no HTTP status code (20x, 40x, etc). Timeouts occur in the TCP layer (connection timeouts, read timeouts) and there is no HTTP response body available.

sandstrom avatar Apr 26 '17 08:04 sandstrom

Hmm, makes sense. If you'd like to make a PR to add this helper function, I'm happy to review it!

alexlafroscia avatar Apr 26 '17 20:04 alexlafroscia

@alexlafroscia Given the plan to (probably) phase out the helpers in favour of instanceOf checks, it would make sense to add an intermediary class in the error hierarchy.

EmberError > AjaxError > HttpError > InvalidError // new
EmberError > AjaxError > HttpError > BadRequestError // new
EmberError > AjaxError > TimeoutError // unchanged

Just want to check if you're open to that too?

sandstrom avatar Apr 27 '17 09:04 sandstrom

Totally, I think that's a great idea!

alexlafroscia avatar Apr 27 '17 20:04 alexlafroscia