Skip to content

Commit

Permalink
when using RemoteData, isError should be true when the http status co…
Browse files Browse the repository at this point in the history
…de is >= 400. Resolves #825
  • Loading branch information
NullVoxPopuli committed Mar 16, 2023
1 parent 1d1147f commit 50ad1ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/hip-actors-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ember-resources": patch
---

when using RemoteData, isError should be true when the http status code is >= 400. Resolves #825"
6 changes: 5 additions & 1 deletion ember-resources/src/util/remote-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ export class State<T = unknown> {

/**
* true if the request throws an exception
* or if the request.status is >= 400
*/
get isError() {
return this.isRejected;
let httpError = this.status && this.status >= 400;
let promiseThrew = this.isRejected;

return httpError || promiseThrew;
}
}

Expand Down

0 comments on commit 50ad1ba

Please sign in to comment.