UMBC-CMSC447-Spring2017-Team5 / college-JUMP

https://lassa.xen.prgmr.com/collegejump/
GNU General Public License v3.0
0 stars 0 forks source link

Catch user creation errors, as with duplicate emails #49

Closed alexander-bauer closed 7 years ago

RyanErnst commented 7 years ago

Need to explicitly write an exception message, fail cleanly, have the website still function, and not show console error message. May require passing message up to front end.

ksilber1 commented 7 years ago

duplicate email, invalid email, password too short, etc.

alexander-bauer commented 7 years ago

The way we should probably accomplish this is that for any page where an error may be thrown, catch the exceptions anywhere they might be thrown via user, and then re-render the same page with an error key set to the exception. Then the template can be responsible for displaying the appropriate message.

Most notable place is the edit accounts page, but we should do this anywhere that we receive a user form.

Mjacks3 commented 7 years ago

@alexander-bauer
I finally found the cause (and replicated) this issue with #37. It's the redirect on valid submission in the views for def edit_accounts_page(): So the redirect function seems to fail on submitting a new user. There is a build error that says something like "could not build endpoint '/edit_accounts' did you mean 'edit_accounts_page' ?"

In my code, the route name is ~@ app.route('/edit_accounts')~ however the function fed into the redirect is return form.redirect(url_for('edit_accounts_page') which refers to the name of page function in the view.

I'm a bit confused because I've used the url_for before but it it normally works the way I think it does. I'm looking up this issue immediately now because it significantly hinders everyone else's progress, but do you have any idea why the function would fail?

Mjacks3 commented 7 years ago

wait no, I fixed that issue by redirecting to the page instead of the form. sweeet

alexander-bauer commented 7 years ago

I'm not convinced coverage is complete, yet, but I think it is as good as we're going to get it. Further improvements should be in the forms, to catch errors as early as possible, and not have to rely on try/except logic.