diff --git a/src/lib/api/accounts.ts b/src/lib/api/accounts.ts index e6f0fe50..3627d69d 100644 --- a/src/lib/api/accounts.ts +++ b/src/lib/api/accounts.ts @@ -88,7 +88,7 @@ export async function setOrg( [CSRF_HEADER_NAME]: csrf_token, }, method: "PATCH", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } diff --git a/src/lib/api/addons.ts b/src/lib/api/addons.ts index 34a74f76..cc61e873 100644 --- a/src/lib/api/addons.ts +++ b/src/lib/api/addons.ts @@ -46,7 +46,7 @@ export async function getAddons( endpoint.searchParams.set(key, String(value)); }); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse>(resp); @@ -83,7 +83,7 @@ export async function getEvent( const endpoint = new URL(`addon_events/${id}/?expand=addon`, BASE_API_URL); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); @@ -108,7 +108,7 @@ export async function history( } const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse>(resp); @@ -127,7 +127,7 @@ export async function scheduled( } const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse>(resp); @@ -154,7 +154,7 @@ export async function dispatch( Referer: APP_URL, }, body: JSON.stringify(payload), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -178,7 +178,7 @@ export async function update( Referer: APP_URL, }, body: JSON.stringify(payload), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -208,7 +208,7 @@ export async function dismiss( Referer: APP_URL, }, body: JSON.stringify({ dismissed: true }), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -234,7 +234,7 @@ export async function cancel( [CSRF_HEADER_NAME]: csrf_token, Referer: APP_URL, }, - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -268,7 +268,7 @@ export async function rate( Referer: APP_URL, }, body: JSON.stringify({ rating: value }), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } diff --git a/src/lib/api/collaborators.ts b/src/lib/api/collaborators.ts index a4849714..96d35aa6 100644 --- a/src/lib/api/collaborators.ts +++ b/src/lib/api/collaborators.ts @@ -38,7 +38,7 @@ export async function add( Referer: APP_URL, }, method: "POST", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -67,7 +67,7 @@ export async function update( Referer: APP_URL, }, method: "PATCH", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -91,7 +91,7 @@ export async function remove( Referer: APP_URL, }, method: "DELETE", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } diff --git a/src/lib/api/documents.ts b/src/lib/api/documents.ts index c9aed190..5be4a5df 100644 --- a/src/lib/api/documents.ts +++ b/src/lib/api/documents.ts @@ -79,7 +79,7 @@ export async function search( } const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); @@ -102,7 +102,7 @@ export async function searchWithin( } } const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); } @@ -127,7 +127,7 @@ export async function get( endpoint.searchParams.set("expand", expand.join(",")); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); @@ -151,7 +151,7 @@ export async function list( } const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); @@ -176,12 +176,12 @@ export async function text( try { url = await getPrivateAsset(url, fetch); } catch (e) { - console.error(e); + console.warn(e); return empty; } } - const resp = await fetch(url).catch(console.error); + const resp = await fetch(url).catch(console.warn); if (!resp || isErrorCode(resp.status)) { return empty; } @@ -204,7 +204,7 @@ export async function textPositions( try { url = await getPrivateAsset(url); } catch (e) { - console.error(e); + console.warn(e); return []; } } @@ -214,7 +214,7 @@ export async function textPositions( if (!resp || isErrorCode(resp.status)) return []; return resp.json(); } catch (e) { - console.error(e); + console.warn(e); return []; } } @@ -242,7 +242,7 @@ export async function create( Referer: APP_URL, }, body: JSON.stringify(doc), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -290,7 +290,7 @@ export async function process( Referer: APP_URL, }, body: JSON.stringify(documents), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -317,7 +317,7 @@ export async function cancel( [CSRF_HEADER_NAME]: csrf_token, Referer: APP_URL, }, - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -339,7 +339,7 @@ export async function destroy( [CSRF_HEADER_NAME]: csrf_token, Referer: APP_URL, }, - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -366,7 +366,7 @@ export async function destroy_many( [CSRF_HEADER_NAME]: csrf_token, Referer: APP_URL, }, - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -397,7 +397,7 @@ export async function edit( Referer: APP_URL, }, body: JSON.stringify(data), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -426,7 +426,7 @@ export async function edit_many( Referer: APP_URL, }, body: JSON.stringify(documents), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -453,7 +453,7 @@ export async function add_tags( Referer: APP_URL, }, body: JSON.stringify(data), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -513,8 +513,8 @@ export async function assetUrl( // assets still processing are in private storage until finished if (document.access !== "public" || String(asset_url).startsWith(DC_BASE)) { asset_url = await getPrivateAsset(asset_url, fetch).catch((e) => { - console.error(e); - console.error(asset_url.href); + console.warn(e); + console.warn(asset_url.href); return asset_url; }); } diff --git a/src/lib/api/flatpages.ts b/src/lib/api/flatpages.ts index 08cee723..1de766f5 100644 --- a/src/lib/api/flatpages.ts +++ b/src/lib/api/flatpages.ts @@ -31,7 +31,7 @@ export async function get( const endpoint = new URL("flatpages" + path, BASE_API_URL); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); diff --git a/src/lib/api/notes.ts b/src/lib/api/notes.ts index 5d2a9e23..4a8e892f 100644 --- a/src/lib/api/notes.ts +++ b/src/lib/api/notes.ts @@ -33,7 +33,7 @@ export async function list( endpoint.searchParams.set("expand", DEFAULT_EXPAND); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse>(resp); @@ -56,7 +56,7 @@ export async function get( endpoint.searchParams.set("expand", DEFAULT_EXPAND); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); @@ -84,7 +84,7 @@ export async function create( Referer: APP_URL, }, method: "POST", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -113,7 +113,7 @@ export async function update( Referer: APP_URL, }, method: "PATCH", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -140,7 +140,7 @@ export async function remove( Referer: APP_URL, }, method: "DELETE", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } diff --git a/src/lib/api/projects.ts b/src/lib/api/projects.ts index 9df9fe90..e2915979 100644 --- a/src/lib/api/projects.ts +++ b/src/lib/api/projects.ts @@ -27,7 +27,7 @@ export async function get( const endpoint = new URL(`projects/${id}/`, BASE_API_URL); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); @@ -47,7 +47,7 @@ export async function list( } const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); return getApiResponse(resp); @@ -129,7 +129,7 @@ export async function pinProject( const resp = await fetch(endpoint, { ...options, body: JSON.stringify({ pinned }), - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -159,7 +159,7 @@ export async function create( Referer: APP_URL, }, method: "POST", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -181,7 +181,7 @@ export async function edit( Referer: APP_URL, }, method: "PATCH", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -204,7 +204,7 @@ export async function destroy( Referer: APP_URL, }, method: "DELETE", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -234,7 +234,7 @@ export async function add( Referer: APP_URL, }, method: "POST", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -259,7 +259,7 @@ export async function remove( Referer: APP_URL, }, method: "DELETE", - }).catch(console.error); + }).catch(console.warn); return getApiResponse(resp); } @@ -283,7 +283,7 @@ export async function documents( endpoint.searchParams.set("per_page", "12"); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); if (!resp) { diff --git a/src/lib/api/sections.ts b/src/lib/api/sections.ts index fddcc894..1a9c40c5 100644 --- a/src/lib/api/sections.ts +++ b/src/lib/api/sections.ts @@ -21,7 +21,7 @@ export async function list( const endpoint = new URL(`documents/${doc_id}/sections.json`, BASE_API_URL); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); if (!resp) { @@ -52,7 +52,7 @@ export async function get( ); const resp = await fetch(endpoint, { credentials: "include" }).catch( - console.error, + console.warn, ); if (!resp) { diff --git a/src/lib/api/tests/addons.test.ts b/src/lib/api/tests/addons.test.ts index ab3ccad8..afe33c60 100644 --- a/src/lib/api/tests/addons.test.ts +++ b/src/lib/api/tests/addons.test.ts @@ -170,9 +170,6 @@ describe("addon payloads", () => { const form = buildForm(parameters); const payload = addons.buildPayload(scraper, form, true); - if (payload.errors) { - console.error(payload.errors); - } expect(payload.valid).toBeTruthy(); expect(payload).toMatchObject({ @@ -203,7 +200,7 @@ describe("addon payloads", () => { const payload = addons.buildPayload(translate, form, true); if (!payload.valid) { - console.error(payload.errors); + console.warn(payload.errors); } // put this after the above test so we can see errors on failure @@ -235,7 +232,7 @@ describe("addon payloads", () => { const payload = addons.buildPayload(translate, form, true); if (!payload.valid) { - console.error(payload.errors); + console.warn(payload.errors); } // put this after the above test so we can see errors on failure diff --git a/src/lib/components/addons/AddOnPin.svelte b/src/lib/components/addons/AddOnPin.svelte index 517ecd97..91fdc21f 100644 --- a/src/lib/components/addons/AddOnPin.svelte +++ b/src/lib/components/addons/AddOnPin.svelte @@ -46,7 +46,7 @@ if (!resp.ok) { // reset active state addon.active = !addon.active; - console.error(`Problem updating add-on: ${resp.statusText}`); + console.warn(`Problem updating add-on: ${resp.statusText}`); } // now that we've updated, set $pinned diff --git a/src/lib/components/addons/History.svelte b/src/lib/components/addons/History.svelte index f9f7d492..bdb7f27b 100644 --- a/src/lib/components/addons/History.svelte +++ b/src/lib/components/addons/History.svelte @@ -28,7 +28,7 @@ loading = true; const resp = await fetch(url, { credentials: "include" }).catch( - console.error, + console.warn, ); const { data: results, error: err } = await getApiResponse>(resp); diff --git a/src/lib/components/addons/Scheduled.svelte b/src/lib/components/addons/Scheduled.svelte index 4f197a9a..cc99a297 100644 --- a/src/lib/components/addons/Scheduled.svelte +++ b/src/lib/components/addons/Scheduled.svelte @@ -25,7 +25,7 @@ loading = true; const resp = await fetch(url, { credentials: "include" }).catch( - console.error, + console.warn, ); const { data: results, error: err } = diff --git a/src/lib/components/documents/ResultsList.svelte b/src/lib/components/documents/ResultsList.svelte index a0b58600..6ea8779a 100644 --- a/src/lib/components/documents/ResultsList.svelte +++ b/src/lib/components/documents/ResultsList.svelte @@ -54,7 +54,7 @@ async function load(url: URL) { loading = true; const resp = await fetch(url, { credentials: "include" }).catch( - console.error, + console.warn, ); const { data, error: err } = await getApiResponse(resp); diff --git a/src/lib/components/processing/AddOns.svelte b/src/lib/components/processing/AddOns.svelte index 4f31e3a4..27261bfc 100644 --- a/src/lib/components/processing/AddOns.svelte +++ b/src/lib/components/processing/AddOns.svelte @@ -64,7 +64,7 @@ This component should update on a timer. rated[run.uuid] = rating; const { data, error } = await rate(run.uuid, rating, csrftoken); if (error || !data) { - console.error(error?.errors ?? "No data"); + console.warn(error?.errors ?? "No data"); restore(); delete rated[run.uuid]; } else { @@ -76,13 +76,13 @@ This component should update on a timer. const restore = optimisticUpdate({ ...run, dismissed: true }); const csrftoken = getCsrfToken(); if (!csrftoken) { - console.error("No CSRF token"); + console.warn("No CSRF token"); restore(); return; } const { data, error } = await dismiss(run.uuid, csrftoken); if (error || !data) { - console.error(error?.errors ?? "No data"); + console.warn(error?.errors ?? "No data"); restore(); } else { optimisticUpdate(data); diff --git a/src/lib/components/projects/ProjectPin.svelte b/src/lib/components/projects/ProjectPin.svelte index bf455826..7128a0ef 100644 --- a/src/lib/components/projects/ProjectPin.svelte +++ b/src/lib/components/projects/ProjectPin.svelte @@ -46,7 +46,7 @@ if (error || !data) { project.pinned = !project.pinned; - console.error(error ?? "Missing data"); + console.warn(error ?? "Missing data"); } else { project = data; await invalidate(canonicalUrl(project)); diff --git a/src/lib/components/viewer/PDF.svelte b/src/lib/components/viewer/PDF.svelte index 566c57cd..409e0189 100644 --- a/src/lib/components/viewer/PDF.svelte +++ b/src/lib/components/viewer/PDF.svelte @@ -46,7 +46,7 @@ } }) .catch((e) => { - console.error(e); + console.warn(e); errors.update((errs) => [...errs, e]); }); @@ -61,7 +61,7 @@ window.pdf = p; }) .catch((e) => { - console.error(e); + console.warn(e); errors.update((errs) => [...errs, e]); }); }); diff --git a/src/lib/utils/api.ts b/src/lib/utils/api.ts index a95deaf6..ffea9013 100644 --- a/src/lib/utils/api.ts +++ b/src/lib/utils/api.ts @@ -46,7 +46,7 @@ export async function getApiResponse( errors: resp.json ? await resp.json() : null, }; } catch (error) { - console.error(error); + console.warn(error); // if we fail parsing the error's JSON, // just return the status response.error = { @@ -121,7 +121,7 @@ export async function getPrivateAsset( headers: { Accept: "application/json", }, - }).catch(console.error); + }).catch(console.warn); // should this be an API response? if (!resp) { diff --git a/src/lib/utils/scroll.ts b/src/lib/utils/scroll.ts index 4bc0f4fb..88a7f729 100644 --- a/src/lib/utils/scroll.ts +++ b/src/lib/utils/scroll.ts @@ -9,6 +9,6 @@ export function scrollToPage(n: number): void { const pageId = pageHashUrl(n).replace("#", ""); const heading = window.document.getElementById(pageId); - if (!heading) return console.error(`Missing page ${n}`); + if (!heading) return console.warn(`Missing page ${n}`); heading.scrollIntoView(); } diff --git a/src/lib/utils/search.ts b/src/lib/utils/search.ts index 87005c32..ddb49a99 100644 --- a/src/lib/utils/search.ts +++ b/src/lib/utils/search.ts @@ -75,7 +75,7 @@ export function pageNumber(page: string): number { export function getQuery(url?: Nullable, param: string = "q"): string { if (!url) { - console.error("Missing URL"); + console.warn("Missing URL"); } return url?.searchParams?.get(param) ?? ""; }