Skip to content

Relates to #831 - Add error handling for data-fetching #832

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions src/api/OpenProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const getCurationSketches = async (
const response = await fetch(
`${openProcessingEndpoint}curation/${curationId}/sketches?${limitParam}`,
);

if (!response.ok) {
//log error instead of throwing error to not cache result in memoize
console.error("getCurationSketches", response.status, response.statusText);
}

const payload = await response.json();
return payload as OpenProcessingCurationResponse;
};
Expand Down Expand Up @@ -78,6 +84,12 @@ export const getSketch = memoize(async (
id: string,
): Promise<OpenProcessingSketchResponse> => {
const response = await fetch(`${openProcessingEndpoint}sketch/${id}`);

if (!response.ok) {
//log error instead of throwing error to not cache result in memoize
console.error("getSketch", id, response.status, response.statusText);
}

const payload = await response.json();
return payload as OpenProcessingSketchResponse;
});
Expand All @@ -89,6 +101,12 @@ export const getSketchSize = memoize(async (id: string) => {
}

const response = await fetch(`${openProcessingEndpoint}sketch/${id}/code`);

if (!response.ok) {
//log error instead of throwing error to not cache result in memoize
console.error("getSketchSize", id, response.status, response.statusText);
}

const payload = await response.json();

for (const tab of payload) {
Expand Down
Loading