Closed ghost closed 7 years ago
If your form is missing a value, then it will say a field is missing in the popup error message.
An example is in the Register form: https://github.com/blue-jay/blueprint/blob/master/controller/register/register.go#L36
You can see the FormValid method in Flight: https://github.com/blue-jay/blueprint/blob/master/lib/flight/flight.go#L103
If you get "an error occurred on the server" message, it means that something went wrong on the back end of the application like the database is unavailable. Do you have a specific example you'd like to go over?
I did encounter similar issue. It is because c.FlashError on https://github.com/blue-jay/blueprint/blob/master/controller/register/register.go#L37
passing correct error but https://github.com/blue-jay/blueprint/blob/master/lib/flight/flight.go#L139 is not using passed error. I replaced the "An error occurred on the server. Please try again later." with err string.
I'm glad you replaced it with your error to fit your needs. Blueprint is supposed to be just a template that you can use in your projects. The Core library is pretty solid, but Blueprint is designed to be modified to fit your use case. You don't even have to use the libraries in Core, I find myself replacing libraries in Core as our projects mature, but it's definitely a solid jumping off point.
I'm going to leave my code the way it is so the user doesn't receive any confusing information on the front end. The actual error is logged for the admin to look at and debug: https://github.com/blue-jay/blueprint/blob/master/lib/flight/flight.go#L138
@josephspurrier When I installed blueprint and let a field empty, there was no error message like 'Field missing: ...', it was 'An error occured on the server...'.
Which field on which screen?
When clicking on 'Create Account': When clicking on 'Login':
What is the error in your CLI? The reason it failed should show there. Send the whole log from your console.
Console output:
2017-02-08 03:31:03 PM [::1]:42660 POST /login
flight.go:138: Field missing: email
When I add a note without content, I get the following error, that seems right:
In my opinion the error from the console should be shown in the frontend for the user to see what he has done wrong.
Thanks for bringing this to my attention. There were two issues. Login and Register should have been using the Flight.FormValid function. Also, I created a new FlashErrorGeneric for errors off MySQL and other things that are not useful to the user.
https://github.com/blue-jay/blueprint/commit/46c382431f4e2a9fdaa552ccd63c8a93921de4a2
I always get "An error occurred on the server. Please try again later.". I think the right way would be to say something like: The email field is missing. It prints it in the server logs, but wouldn't that be a message the user wants to see? Hope you get what I mean.