Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error to contact form if submission fails #9564

Merged
merged 2 commits into from
Jun 24, 2024

Conversation

danieljames-dj
Copy link
Member

Currently if there is an error for the contact form submission, we are not informing the user of the same. This PR is to achieve that.

@@ -66,6 +68,7 @@ export default function ContactForm({ loggedInUserData }) {
}, [selectedContactRecipient]);

if (saving) return <Loading />;
if (saveError) return <Errored error={saveError} />;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error handler of our useSaveAction returns the actual error object. This means that the Errored property here might end up just displaying: "An error occured! Details: [Object object]".

Have you tested this? You can temporarily modify the backend controller to just execute raise "Something went horribly wrong!" directly as the first line, to simulate an error. And then see how the frontend behaves.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it returns error object. If I do raise "Something went horribly wrong!", it will show some weird error:
Screenshot 2024-06-24 at 7 06 57 AM

But instead for return render status: :bad_request, json: { error: "Invalid arguments" }, I'll get following:
Screenshot 2024-06-24 at 7 08 11 AM

The last one is the current behavior. Is this fine or do you have an alternative suggestion?

(I also just realized I missed to add return for that error in contact_controller. Added it now)

@danieljames-dj danieljames-dj merged commit 8afc652 into thewca:main Jun 24, 2024
1 check passed
@danieljames-dj danieljames-dj deleted the contact-error branch June 24, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants