You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/10/10 01:59:33 UTC
svn commit: r1396418 - in
/incubator/mesos/trunk/third_party/libprocess/include: process/future.hpp
stout/result.hpp stout/try.hpp
Author: benh
Date: Tue Oct 9 23:59:33 2012
New Revision: 1396418
URL: http://svn.apache.org/viewvc?rev=1396418&view=rev
Log:
Added error diagnostics to Try, Result, and Future assertions
(contributed by Ben Mahler, https://reviews.apache.org/r/7185).
Modified:
incubator/mesos/trunk/third_party/libprocess/include/process/future.hpp
incubator/mesos/trunk/third_party/libprocess/include/stout/result.hpp
incubator/mesos/trunk/third_party/libprocess/include/stout/try.hpp
Modified: incubator/mesos/trunk/third_party/libprocess/include/process/future.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/future.hpp?rev=1396418&r1=1396417&r2=1396418&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/future.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/future.hpp Tue Oct 9 23:59:33 2012
@@ -4,6 +4,7 @@
#include <assert.h>
#include <stdlib.h> // For abort.
+#include <iostream>
#include <list>
#include <queue>
#include <set>
@@ -528,7 +529,15 @@ T Future<T>::get() const
await();
}
+ CHECK(!isPending()) << "Future was in PENDING after await()";
+
if (!isReady()) {
+ if (isFailed()) {
+ std::cerr << "Future::get() but state == FAILED: "
+ << failure() << std::endl;
+ } else if (isDiscarded()) {
+ std::cerr << "Future::get() but state == DISCARDED" << std::endl;
+ }
abort();
}
Modified: incubator/mesos/trunk/third_party/libprocess/include/stout/result.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/stout/result.hpp?rev=1396418&r1=1396417&r2=1396418&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/stout/result.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/stout/result.hpp Tue Oct 9 23:59:33 2012
@@ -3,6 +3,7 @@
#include <assert.h>
+#include <iostream>
#include <string>
@@ -62,7 +63,19 @@ public:
bool isNone() const { return state == NONE; }
bool isError() const { return state == ERROR; }
- T get() const { assert(state == SOME); return *t; }
+ T get() const
+ {
+ if (state != SOME) {
+ if (state == ERROR) {
+ std::cerr << "Result::get() but state == ERROR: "
+ << error() << std::endl;
+ } else if (state == NONE) {
+ std::cerr << "Result::get() but state == NONE" << std::endl;
+ }
+ abort();
+ }
+ return *t;
+ }
std::string error() const { assert(state == ERROR); return message; }
Modified: incubator/mesos/trunk/third_party/libprocess/include/stout/try.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/stout/try.hpp?rev=1396418&r1=1396417&r2=1396418&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/stout/try.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/stout/try.hpp Tue Oct 9 23:59:33 2012
@@ -3,6 +3,7 @@
#include <assert.h>
+#include <iostream>
#include <string>
@@ -57,7 +58,14 @@ public:
bool isSome() const { return state == SOME; }
bool isError() const { return state == ERROR; }
- T get() const { assert(state == SOME); return *t; }
+ T get() const
+ {
+ if (state != SOME) {
+ std::cerr << "Try::get() but state == ERROR: " << error() << std::endl;
+ abort();
+ }
+ return *t;
+ }
std::string error() const { assert(state == ERROR); return message; }