Send HTTP 400 or 500 instead of crashing.