Skip to content

Commit

Permalink
chore: add code rabbit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
chalabi2 committed Jan 8, 2025
1 parent ec5c6d3 commit 5608a08
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion components/factory/forms/CreateDenom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,19 @@ export default function CreateDenom({
await DenomSchema.validate(values, { abortEarly: false });
nextStep();
} catch (err) {
console.error('Validation failed:', err);
if (err instanceof Yup.ValidationError) {
const errors = err.inner.reduce(
(acc: Record<string, string>, error) => ({
...acc,
[error.path as string]: error.message,
}),
{}
);
setErrors(errors);
} else {
console.error('Unexpected error:', err);
setErrors({ subdenom: 'An unexpected error occurred' });
}
} finally {
setSubmitting(false);
}
Expand Down

0 comments on commit 5608a08

Please sign in to comment.