Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Unified Diff: mojo/public/cpp/bindings/lib/validation_errors.cc

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.h ('k') | mojo/public/cpp/bindings/lib/validation_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ea6aff8f151ca70867bf3e9e37f0ee684450ba16 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,19 +53,38 @@ 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) {
+ return;
+ }
+
+ if (description) {
LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error) << " ("
<< description << ")";
+ if (context->message()) {
+ context->message()->NotifyBadMessage(
+ base::StringPrintf("Validation failed for %s [%s (%s)]",
+ context->description().data(),
+ ValidationErrorToString(error), description));
+ }
} else {
LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error);
+ if (context->message()) {
+ context->message()->NotifyBadMessage(
+ base::StringPrintf("Validation failed for %s [%s]",
+ context->description().data(),
+ ValidationErrorToString(error)));
+ }
}
}
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.h ('k') | mojo/public/cpp/bindings/lib/validation_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698