-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
When using @chain-registry/client via starshipjs, I observed a generic Bad response error and had trouble tracking down the root cause of an issue.
I came to learn the starship registry service returned a helpful error message:
{"code":2, "message":"not found: no ibc connection found between chainA and chainB", "details":[]}But it was swallowed by the client:
https://github.com/cosmology-tech/chain-registry/blob/b3b39185825b46807816e07d427935c56938923a/v1/packages/client/src/fetcher.ts#L13-L20
Changes along these lines should surface reported errors:
const fetchUrl = async (url: string) => {
const res = await fetch(url);
const data = await res.json();
if (!res.ok) {
// If the response contains error information, use it
if (data && data.code !== undefined && data.message) {
const error = new Error(data.message) as Error & {
code?: number;
details?: any[];
};
error.code = data.code;
error.details = data.details;
throw error;
} else {
throw new Error(`Bad Response: ${res.status}`);
}
}
return data;
};Metadata
Metadata
Assignees
Labels
No labels