Skip to content

Commit

Permalink
Do not log errors unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Apr 1, 2024
1 parent f5dda4b commit 9dd3a95
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ export class RemoteIPyWidgetScriptManager extends BaseIPyWidgetScriptManager imp
protected async getWidgetScriptSource(script: Uri): Promise<string> {
const httpClientResponse = this.getWidgetScriptSourceUsingHttpClient(script);
const fetchResponse = this.getWidgetScriptSourceUsingFetch(script);
return httpClientResponse.catch(() => fetchResponse);
const promise = httpClientResponse.catch(() => fetchResponse);
// If we fail to download using both mechanisms, then log an error.
promise.catch((ex) => {
httpClientResponse.catch((ex) =>
traceError(`Failed to download widget script source from ${script.toString(true)}`, ex)
);
traceError(`Failed to download widget script source from ${script.toString(true)}`, ex);
});
return promise;
}
private async getWidgetScriptSourceUsingHttpClient(script: Uri): Promise<string> {
const uri = script.toString(true);
Expand All @@ -141,7 +149,6 @@ export class RemoteIPyWidgetScriptManager extends BaseIPyWidgetScriptManager imp
if (response.status === 200) {
return response.text();
} else {
traceError(`Error downloading from ${uri}: ${response.statusText}`);
throw new Error(`Error downloading from ${uri}: ${response.statusText}`);
}
}
Expand All @@ -154,7 +161,6 @@ export class RemoteIPyWidgetScriptManager extends BaseIPyWidgetScriptManager imp
if (response.status === 200) {
return response.text();
} else {
traceError(`Error downloading from ${uri} using custom fetch: ${response.statusText}`);
throw new Error(`Error downloading from ${uri} using custom fetch: ${response.statusText}`);
}
}
Expand Down

0 comments on commit 9dd3a95

Please sign in to comment.