diff --git a/common/src/util/api.ts b/common/src/util/api.ts index a23a04ed..441148a5 100644 --- a/common/src/util/api.ts +++ b/common/src/util/api.ts @@ -50,7 +50,7 @@ export async function typedAPICall

( } if (!resp.ok) { - throw new APIError(resp.status as any, json?.message, json?.details) + throw new APIError(resp.status as any, json?.error?.message, json?.error?.details) } return json }) as APIResponse

diff --git a/web/pages/profile.tsx b/web/pages/profile.tsx index 9631071b..fec7b800 100644 --- a/web/pages/profile.tsx +++ b/web/pages/profile.tsx @@ -1,3 +1,4 @@ +import {APIError} from 'common/api/utils' import {debug} from 'common/logger' import {Profile, ProfileWithoutUser} from 'common/profiles/profile' import {BaseUser, User} from 'common/user' @@ -85,10 +86,12 @@ function ProfilePageInner(props: {user: User; profile: Profile}) { try { await Promise.all(promises) } catch (error) { - console.error(error) - toast.error( - `We ran into an issue saving your profile. Please try again or contact us if the issue persists.`, - ) + let message = + 'We ran into an issue saving your profile. Please try again or contact us if the issue persists.' + if (error instanceof APIError) { + message = `Error: ` + JSON.stringify(error.toJSON().error.details) + } + toast.error(message) return } Router.push(`/${user.username}`)