Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove console.error and report non-success responses (#1092) #1093

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/libs/http-utils/src/FetchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,19 @@ export abstract class FetchClient {
protected readonly baseUrl: string;
protected readonly init: RequestInit;
protected readonly fetchApi: Window['fetch'];
protected readonly onNonSuccessResponse: FetchApiOptions['onNonSuccessResponse'];
// Subclasses can set this to false to disable including a traceparent header with all requests.
protected readonly includeTraceidHeader: boolean = true;
protected get onNonSuccessResponse() {
return this._onNonSuccessResponse ?? FetchClient.onNonSuccessResponse;
}

private readonly _onNonSuccessResponse: FetchApiOptions['onNonSuccessResponse'];

constructor(options: FetchApiOptions) {
this.baseUrl = options.baseUrl;
this.init = options.init ?? {};
this.fetchApi = options.fetchApi ?? window.fetch;
this.onNonSuccessResponse =
options.onNonSuccessResponse ?? FetchClient.onNonSuccessResponse;
this._onNonSuccessResponse = options.onNonSuccessResponse;
}

/**
Expand Down
17 changes: 0 additions & 17 deletions packages/libs/user-datasets/src/lib/Hooks/user-datasets.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/libs/user-datasets/src/lib/Service/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,15 @@ export class UserDatasetApi extends FetchClientWithCredentials {
const response = JSON.parse(xhr.response);
dispatchUploadProgress && dispatchUploadProgress(null);
dispatchPageRedirect && dispatchPageRedirect(response.datasetId);
} catch (error) {
} finally {
dispatchUploadProgress && dispatchUploadProgress(null);
console.error(error);
}
}
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status >= 400) {
const error = new Error(xhr.response);
dispatchUploadProgress && dispatchUploadProgress(null);
dispatchBadUpload && dispatchBadUpload(String(error));
console.log(error);
this.onNonSuccessResponse?.(error);
}
});

Expand Down
Loading