Skip to content

Commit

Permalink
🐛 Fix catcher priority
Browse files Browse the repository at this point in the history
Specifying the name of an error had a higher priority when cathing errors than statuses, which was never intended.
See #162 on how it allows to create global error listeners using resolvers.
  • Loading branch information
elbywan committed Jan 11, 2023
1 parent 969d59f commit d359bd7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ export const resolver = <T, Chain, R>(wretch: T & Wretch<T, Chain, R>) => {
const error = err.__wrap || err

const catcher =
(error.status && catchers.get(error.status)) ||
catchers.get(error.name) || (
err.__wrap && catchers.has(FETCH_ERROR)
? catchers.get(FETCH_ERROR)
: catchers.get(error.status)
err.__wrap && catchers.has(FETCH_ERROR) && catchers.get(FETCH_ERROR)
)

if (catcher)
Expand Down

0 comments on commit d359bd7

Please sign in to comment.