harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
37 stars 30 forks source link

Don't raise server errors for user-input errors #1819

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

The Edit Resource form (and others) have a pattern like:

if form.is_valid():
    form.save()
else:
    return server_error(request)

which when combined with potentially-common user mistakes (like entering the wrong type of content) generates spurious 500 errors and doesn't give the user enough info to correct their mistakes.

It would probably be better to: