Skip to content

Commit

Permalink
DustAPI CoreAPI better error handling (#5703)
Browse files Browse the repository at this point in the history
* DustAPI CoreAPI better error handling

* fix

* fix

* fix

* nit
  • Loading branch information
spolu authored Jun 18, 2024
1 parent 0fe2ed6 commit 8039386
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 77 deletions.
7 changes: 4 additions & 3 deletions types/src/front/lib/connectors_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,23 +532,24 @@ export class ConnectorsAPI {
}

private async _fetchWithError(
input: RequestInfo,
url: string,
init?: RequestInit
): Promise<
Result<{ response: Response; duration: number }, ConnectorsAPIError>
> {
const now = Date.now();
try {
const res = await fetch(input, init);
const res = await fetch(url, init);
return new Ok({ response: res, duration: Date.now() - now });
} catch (e) {
const duration = Date.now() - now;
const err: ConnectorsAPIError = {
type: "unexpected_network_error",
message: "Unexpected network error from ConnectorAPI",
message: `Unexpected network error from ConnectorsAPI: ${e}`,
};
this._logger.error(
{
url,
duration,
connectorsError: err,
error: e,
Expand Down
Loading

0 comments on commit 8039386

Please sign in to comment.