I have a large web system written on top of WSGI that uses webob to access form data (no framework is involved). Randomly we'll get unhandled exceptions of UnicodeDecodeError from browsers (or bots) sending in undecodable escape sequences in the query string or POST data. I'm looking for a good default behavior that doesn't involve me getting an unhandled exception email.
My first idea would be to write a site-wide middleware that accesses the params of a webob request object with an exception handler that returns back a 400 (or maybe strips out the un-decodable data).
How do other systems/frameworks handle this?