summaryrefslogtreecommitdiff
path: root/src/mongo/util/assert_util.h
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-04-03 11:33:28 -0400
committerAdam Midvidy <amidvidy@gmail.com>2015-04-03 13:47:40 -0400
commit78aa03b4eda2784ae67eba32d6b103166f1c57ad (patch)
tree0da01488fe8499ec28cb49d3aa61073c28c62f1e /src/mongo/util/assert_util.h
parent998cf155edc16019758d163e8f844c0986996bcf (diff)
downloadmongo-78aa03b4eda2784ae67eba32d6b103166f1c57ad.tar.gz
SERVER-17850 add utility to convert an exception to a Status
Diffstat (limited to 'src/mongo/util/assert_util.h')
-rw-r--r--src/mongo/util/assert_util.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h
index 0e33e404bdf..bb0f9f17cb8 100644
--- a/src/mongo/util/assert_util.h
+++ b/src/mongo/util/assert_util.h
@@ -324,6 +324,26 @@ namespace mongo {
std::string demangleName( const std::type_info& typeinfo );
+ /**
+ * A utility function that converts an exception to a Status.
+ * Only call this function when there is an active exception
+ * (e.g. in a catch block).
+ *
+ * Note: this technique was created by Lisa Lippincott.
+ *
+ * Example usage:
+ *
+ * Status myFunc() {
+ * try {
+ * funcThatThrows();
+ * return Status::OK();
+ * } catch (...) {
+ * return exceptionToStatus();
+ * }
+ * }
+ */
+ Status exceptionToStatus();
+
} // namespace mongo
#define MONGO_ASSERT_ON_EXCEPTION( expression ) \