From becb43d111bb98a47b736afc52f7f587a93713ee Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:39:32 -0800 Subject: [PATCH] group-members-page: Handle unknown errors I'm not sure if it's possible for a non-Error error to be thrown in these parts, but TypeScript thinks it is possible and it's easy to handle. --- static-site/src/sections/group-members-page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static-site/src/sections/group-members-page.tsx b/static-site/src/sections/group-members-page.tsx index dd180b2ad..3b8f6d48a 100644 --- a/static-site/src/sections/group-members-page.tsx +++ b/static-site/src/sections/group-members-page.tsx @@ -40,7 +40,7 @@ const GroupMembersPage = ({ groupName }: {groupName: string}) => { roles = await rolesResponse.json(); members = await membersResponse.json(); } catch (err) { - const errorMessage = (err as Error).message + const errorMessage = err instanceof Error ? err.message : String(err) if(!ignore) { setErrorMessage({ title: "An error occurred when trying to fetch group membership data", @@ -150,7 +150,7 @@ export async function canViewGroupMembers(groupName: string) { const allowedMethods = new Set(groupMemberOptions.headers.get("Allow")?.split(/\s*,\s*/)); return allowedMethods.has("GET"); } catch (err) { - const errorMessage = (err as Error).message + const errorMessage = err instanceof Error ? err.message : String(err) console.error("Cannot check user permissions to view group members", errorMessage); } return false