Skip to content

Commit

Permalink
Add try/catch for updatePoolsCache()
Browse files Browse the repository at this point in the history
  • Loading branch information
bathord committed May 9, 2024
1 parent fedbb41 commit 5c3d11a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/providers/interest/interest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,19 @@ export class InterestProtocolSingleton extends EventEmitter implements IPoolProv
* @return {Promise<void>}
*/
private async updatePoolsCache(): Promise<void> {
const { pools }: { pools: readonly InterestPool[] } = await this.interestSdk.getPools();
const isValidPoolsResponse = isApiResponseValid(pools);
try {
const { pools }: { pools: readonly InterestPool[] } = await this.interestSdk.getPools();
const isValidPoolsResponse = isApiResponseValid(pools);

if (!isValidPoolsResponse) {
console.error("[Interest] Pools response:", pools);
throw new Error("Pools response from API is not valid");
}
if (!isValidPoolsResponse) {
console.error("[Interest] Pools response:", pools);
throw new Error("Pools response from API is not valid");
}

this.poolsCache = pools;
this.poolsCache = pools;
} catch (error) {
console.error("[Interest.updatePoolsCache]:", error);
}
}

/**
Expand Down

0 comments on commit 5c3d11a

Please sign in to comment.