Skip to content

Commit

Permalink
group-members-page: Handle unknown errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
victorlin committed Nov 19, 2024
1 parent 1726249 commit becb43d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions static-site/src/sections/group-members-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit becb43d

Please sign in to comment.