https://falcon.readthedocs.io/en/latest/api/api.html#falcon.API.set_error_serializer
def my_serializer(req, resp, exception):
representation = None
preferred = req.client_prefers((falcon.MEDIA_YAML, falcon.MEDIA_JSON))
if preferred is not None:
if preferred == falcon.MEDIA_JSON:
resp.data = exception.to_json()
else:
resp.text = yaml.dump(exception.to_dict(), encoding=None)
resp.content_type = preferred
resp.append_header('Vary', 'Accept')
app.set_error_serializer(my_serializer) # 错误输出xml转换成json