Skip to content

Commit

Permalink
Fix: don't throw error on 404 from search service (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Jul 20, 2023
1 parent 36166e8 commit 6530b16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/api/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import {createAxios} from "@/api/general.js";

export class RequestFailedError extends Error { }
export class RequestFailedError extends Error {
constructor(response) {
super(response);
this.code = response.status;
if (typeof response !== 'string') {
this.message = response.statusText;
}
}
}

export class SearchService {
constructor(baseURL) {
Expand Down Expand Up @@ -84,7 +92,15 @@ export class SearchService {

alias(network, address) {
return this.api.get(`/v1/account/${network}/${address}`,)
.then(response => getAccountAlias(response.data))
.then(response => {
if (response.status == 200){
return getAccountAlias(response.data)
} else if (response.status == 204){
return
} else {
throw new RequestFailedError(response);
}
})
}

mimeTypes() {
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ api.getConfig().then(response => {
this.aliases.add(`${network}_${address}`, result);
return result;
})
.catch(err => console.log(err));
.catch(err => console.error(err));
}
}
});
Expand Down

0 comments on commit 6530b16

Please sign in to comment.