From f76594491c98f675ff4ac9943fff80fbd059528e Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Thu, 31 Oct 2024 16:40:37 -0400 Subject: [PATCH 1/2] Include more robust error statement for embargoed 403 dandiset response --- .../DandisetPage/DandisetViewFromDendro/DandisetView.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx b/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx index ddd86d5..3c97f36 100644 --- a/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx +++ b/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx @@ -329,6 +329,12 @@ export const useQueryDandiset = ( const json = await response.json(); const dandisetResponse = json as DandisetSearchResultItem; setDandisetResponse(dandisetResponse); + } else if (response.status === 403) { + console.error( + `Error fetching dandiset due to permissions. If this dandiset is embargoed, ` + + "make sure to set your DANDI_API_KEY under the key icon in the top right corner", response + ); + setDandisetResponse(null); } else { console.error("Error fetching dandiset", response); setDandisetResponse(null); From 8e7624efa7ecbd96fb8a358e58a4a1927ac9be38 Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Thu, 31 Oct 2024 16:45:20 -0400 Subject: [PATCH 2/2] simplify when to return if 200 occurs --- .../DandisetPage/DandisetViewFromDendro/DandisetView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx b/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx index 3c97f36..2743317 100644 --- a/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx +++ b/gui/src/app/pages/DandisetPage/DandisetViewFromDendro/DandisetView.tsx @@ -329,16 +329,16 @@ export const useQueryDandiset = ( const json = await response.json(); const dandisetResponse = json as DandisetSearchResultItem; setDandisetResponse(dandisetResponse); + return; } else if (response.status === 403) { console.error( `Error fetching dandiset due to permissions. If this dandiset is embargoed, ` + "make sure to set your DANDI_API_KEY under the key icon in the top right corner", response ); - setDandisetResponse(null); } else { console.error("Error fetching dandiset", response); - setDandisetResponse(null); } + setDandisetResponse(null); } catch (e) { console.error("Error fetching dandiset", e); setDandisetResponse(null);