Skip to content

Commit

Permalink
fix: improved error response format
Browse files Browse the repository at this point in the history
  • Loading branch information
darkoatanasovski committed Dec 12, 2022
1 parent bc033fc commit dfc1586
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/components/Account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ const Account = ({ panelClassName, panelHeaderClassName, canUpdateEmail = true }
const formErrors: FormErrors = {};
// Some errors are combined in a single CSV string instead of one string per error
errors
?.flatMap((e) => {
if (typeof e === 'object') {
return e?.['message'];
}
return e.split(',');
})
?.flatMap((e) => e.split(','))
.forEach((error) => {
switch (error.trim()) {
case 'Invalid param email':
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/FormSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function FormSection<TData extends GenericFormValues>({
});
response = await onSubmit(values);
} catch (error: unknown) {
response = { errors: Array.of(error as string) };
response = { errors: Array.of(error instanceof Error ? error.message : (error as string)) };
}

// Don't leave edit mode if there are errors
Expand Down

0 comments on commit dfc1586

Please sign in to comment.