make Range::size() constexpr
[folly.git] / folly / ExceptionWrapper.h
index 7a5610b73bd4d6de1bdc58e012c446c139425b20..22857a0b9b543259f504e52dc9283b9bf023db52 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef FOLLY_EXCEPTIONWRAPPER_H
-#define FOLLY_EXCEPTIONWRAPPER_H
+#pragma once
 
 #include <cassert>
 #include <exception>
@@ -88,16 +87,15 @@ namespace folly {
  *
  * // Thread2: Exceptions are bad!
  * void processResult() {
- *   auto ep = globalExceptionWrapper.get();
- *   if (!ep.with_exception([&](
- *     FacePlantException& faceplant) {
- *       LOG(ERROR) << "FACEPLANT";
- *     })) {
- *     ep.with_exception([&](
- *       FailWhaleException& failwhale) {
+ *   globalExceptionWrapper.with_exception(
+ *       [&](FacePlantException& faceplant) {
+ *         LOG(ERROR) << "FACEPLANT";
+ *       }) ||
+ *   globalExceptionWrapper.with_exception(
+ *       [&](FailWhaleException& failwhale) {
  *         LOG(ERROR) << "FAILWHALE!";
- *       });
- *   }
+ *       }) ||
+ *   LOG(FATAL) << "Unrecognized exception";
  * }
  *
  */
@@ -469,4 +467,3 @@ class try_and_catch<> : public exception_wrapper {
   }
 };
 }
-#endif