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

Expose error codes #318

Merged
merged 4 commits into from Nov 30, 2017
Merged

Conversation

spruce
Copy link
Contributor

@spruce spruce commented Oct 16, 2017

As written in #275 it would make sense to expose the actual http status codes outside of the default error classes.
Only thing I can see which blocked the PR was this: #275 (review)
So I tried to do everything of it. Only thing I couldn't achieve is to make it a switch statement. (I don't think it's possible, cause case expects only a value and not a expression and function calls are expressions. Right??? I'm really unsure but would like to know if I'm right or not)

Happy to work some more to get it merged 馃憖

@alexlafroscia
Copy link
Collaborator

Hey @spruce, sorry this has sat so long. I'm getting back into OSS now and would love to help get this landed.

To start, there's a merge conflict now. Mind taking a look at that?

@@ -879,6 +881,7 @@ describe('Unit | Mixin | ajax request', function() {
.catch(function(reason) {
expect(isTimeoutError(reason)).to.be.ok;
expect(reason.payload).to.be.null;
expect(reason.status).to.equal(-1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this -1 come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤

return this._createCorrectError(status, headers, payload, requestData);
},

_createCorrectError(status, headers, payload, requestData) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for breaking this out into a separate method, rather than just adding the logic to the existing handleResponse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually came from a request you had: #275 (review)
Or did I misunderstand something there?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair 馃槄 That review was so long ago. I'm fine with merging as-is. I'm working on a pretty major refactor so might clean it up later if it's bugging me.

@spruce
Copy link
Contributor Author

spruce commented Nov 27, 2017

Will work on it. Would still like for this to get merged. I'm going to work on this now.

Ben Demboski and others added 4 commits November 27, 2017 22:05
There may be cases where callers want access to the status code that caused the error (e.g. logging/metrics, or terse user-facing error messages), so this allows them to easily get at it.
return this._createCorrectError(status, headers, payload, requestData);
},

_createCorrectError(status, headers, payload, requestData) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair 馃槄 That review was so long ago. I'm fine with merging as-is. I'm working on a pretty major refactor so might clean it up later if it's bugging me.

@@ -879,6 +881,7 @@ describe('Unit | Mixin | ajax request', function() {
.catch(function(reason) {
expect(isTimeoutError(reason)).to.be.ok;
expect(reason.payload).to.be.null;
expect(reason.status).to.equal(-1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤

@alexlafroscia alexlafroscia merged commit 3314904 into ember-cli:master Nov 30, 2017
@mehulkar
Copy link

mehulkar commented Mar 8, 2018

@spruce @alexlafroscia Thanks for getting this in! Could we get it into a patch release? I want my 502/503 codes 馃槃

@alexlafroscia
Copy link
Collaborator

Yeah, I think I should be able to cut a release, it doesn't seem like there's anything that's landed between then and now that would be breaking. Sorry this has lingered so long, I didn't realize the last major release was back in April!

@alexlafroscia
Copy link
Collaborator

@mehulkar
Copy link

mehulkar commented Mar 9, 2018

@alexlafroscia thank you!

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

Successfully merging this pull request may close these issues.

None yet

3 participants