Chromium Code Reviews| Index: mojo/public/cpp/bindings/lib/validation_errors.cc |
| diff --git a/mojo/public/cpp/bindings/lib/validation_errors.cc b/mojo/public/cpp/bindings/lib/validation_errors.cc |
| index e5743eb8a16c8618a854e2260642ed1a8aa392a5..8a0f03d2ff7b8756a3beabd8eba9169aa7530838 100644 |
| --- a/mojo/public/cpp/bindings/lib/validation_errors.cc |
| +++ b/mojo/public/cpp/bindings/lib/validation_errors.cc |
| @@ -4,6 +4,9 @@ |
| #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "mojo/public/cpp/bindings/message.h" |
| + |
| namespace mojo { |
| namespace internal { |
| namespace { |
| @@ -50,12 +53,16 @@ const char* ValidationErrorToString(ValidationError error) { |
| return "VALIDATION_ERROR_UNKNOWN_UNION_TAG"; |
| case VALIDATION_ERROR_UNKNOWN_ENUM_VALUE: |
| return "VALIDATION_ERROR_UNKNOWN_ENUM_VALUE"; |
| + case VALIDATION_ERROR_DESERIALIZATION_FAILED: |
| + return "VALIDATION_ERROR_DESERIALIZATION_FAILED"; |
| } |
| return "Unknown error"; |
| } |
| -void ReportValidationError(ValidationError error, const char* description) { |
| +void ReportValidationError(ValidationContext* context, |
| + ValidationError error, |
| + const char* description) { |
| if (g_validation_error_observer) { |
| g_validation_error_observer->set_last_error(error); |
| } else if (description) { |
| @@ -64,6 +71,20 @@ void ReportValidationError(ValidationError error, const char* description) { |
| } else { |
| LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); |
| } |
| + |
| + if (context->message()) { |
|
yzshen1
2016/06/15 22:20:09
When g_validation_error_observer is set, we are in
Ken Rockot(use gerrit already)
2016/06/15 22:38:23
I guess not. Done.
|
| + if (description) { |
| + context->message()->NotifyBadMessage( |
| + base::StringPrintf("Validation failed for %s [%s (%s)]", |
| + context->description().data(), |
| + ValidationErrorToString(error), description)); |
| + } else { |
| + context->message()->NotifyBadMessage( |
| + base::StringPrintf("Validation failed for %s [%s]", |
| + context->description().data(), |
| + ValidationErrorToString(error))); |
| + } |
| + } |
| } |
| ValidationErrorObserverForTesting::ValidationErrorObserverForTesting( |