Fix content negotiation in error handling

Fixes #398.