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

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

Issue 1387993002: mojo::Serialize*_() calls now propogate/return validation errors. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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
Index: mojo/public/cpp/bindings/lib/validation_errors.h
diff --git a/mojo/public/cpp/bindings/lib/validation_errors.h b/mojo/public/cpp/bindings/lib/validation_errors.h
index 43059c2e22b8ee6c18a089b1381bbdf4df66edb2..0364bae2ae1842e8bc116ecad9e3c5f3c6c5af37 100644
--- a/mojo/public/cpp/bindings/lib/validation_errors.h
+++ b/mojo/public/cpp/bindings/lib/validation_errors.h
@@ -119,4 +119,16 @@ class SerializationWarningObserverForTesting {
<< ValidationErrorToString(error) << " at the receiving side (" \
<< description << ").";
viettrungluu 2015/10/06 16:40:06 Drive-by: It's rather odd that this macro ends wit
vardhan 2015/10/06 22:57:14 Done.
+// If condition is true, we either report or make a fatal log message, and then
+// return.
+#define MOJO_INTERNAL_SERIALIZATION_CHECK_AND_RETURN(condition, return_code, \
viettrungluu 2015/10/06 16:40:06 (This is not a well-written macro, for a number of
vardhan 2015/10/06 22:57:14 Ah, I didn't think about this enough, that's a goo
+ description) \
+ if (condition) { \
+ MOJO_DLOG_IF(FATAL, !ReportSerializationWarning(return_code)) \
+ << "The outgoing message will trigger " \
+ << ValidationErrorToString(return_code) << " at the receiving side (" \
+ << description << ")."; \
+ return return_code; \
viettrungluu 2015/10/06 16:40:06 But in general, I don't think it's a good idea to
vardhan 2015/10/06 22:57:14 I did something like [2]. PTAL!
+ }
+
#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_

Powered by Google App Engine
This is Rietveld 408576698