Properly marshal JSON error messages.