toResponse method
dynamic
toResponse()
the JSON body of the error answer:
{"code": "not_found", "message": "Not Found"}.
a Map message is sent as it is, so validation errors and
custom JSON keep their own shape.
Implementation
dynamic toResponse() {
if (message is Map) {
return message;
}
return <String, dynamic>{'code': errorCode, 'message': message.toString()};
}