Handling Form errors and exceptions

This post might be helpful: A carefully written question about user-facing forms

Also this gist, while it’s all about sending emails, the idea is the same.