Skip to content

Commit

Permalink
Do not log errors unnecessarily (#15456)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Apr 1, 2024
1 parent 964503f commit f257c4b
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 f257c4b

Please sign in to comment.