JDShu / SCOPE

Other
0 stars 2 forks source link

Handle Validation Error Gracefully #188

Open maxwward opened 11 years ago

maxwward commented 11 years ago

When user tries to add a problem to an exercise and accidentally clicks the button to submit before filling in anything an epic error is thrown.

It's right to tell the user she didn't enter what she needed to, but not with a crash message like this:

image

Traceback:

Environment:

Request Method: POST Request URL: http://scopeproject.herokuapp.com/exercises/4/problem/

Django Version: 1.3.1 Python Version: 2.7.4 Installed Applications: ['longerusername', 'django_extensions', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.humanize', 'django.contrib.sitemaps', 'askbot', 'askbot.deps.django_authopenid', 'south', 'askbot.deps.livesettings', 'keyedcache', 'robots', 'django_countries', 'djcelery', 'djkombu', 'followit', 'tinymce', 'storages', 'boto'] Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware', 'askbot.middleware.forum_mode.ForumModeMiddleware', 'askbot.middleware.cancel.CancelActionMiddleware', 'django.middleware.transaction.TransactionMiddleware', 'askbot.middleware.view_log.ViewLogMiddleware', 'askbot.middleware.spaceless.SpacelessMiddleware')

Traceback: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/app/askbot/utils/decorators.py" in wrapper
  2. return view_func(request, _args, *_kwargs) File "/app/askbot/utils/decorators.py" in wrapper
  3. return view_func(request, _args, *_kwargs) File "/app/askbot/views/writers.py" in problem
  4. timestamp = update_time, File "/app/askbot/models/init.py" in user_post_problem
  5. by_email = by_email File "/app/askbot/models/post.py" in create_new_problem
  6. by_email = by_email File "/app/askbot/models/post.py" in create_new
  7. by_email = by_email File "/app/askbot/models/post.py" in add_revision
  8. return self.__add_revision(_kargs, *_kwargs) File "/app/askbot/models/post.py" in __add_revision
  9. by_email = by_email File "/app/askbot/models/post.py" in create
  10. revision = super(PostRevisionManager, self).create(_kargs, *_kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/manager.py" in create
  11. return self.get_query_set().create(**kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py" in create
  12. obj.save(force_insert=True, using=self.db) File "/app/askbot/models/post.py" in save
  13. self.full_clean() File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/base.py" in full_clean
  14. raise ValidationError(errors)

Exception Type: ValidationError at /exercises/4/problem/ Exception Value: {'text': [u'This field cannot be blank.']}

tyrrminal commented 11 years ago

Right, we disabled interactive validation of that field because the error message was appearing inappropriately, and never replaced it with anything