Add element construction/destruction hooks to IndexedMemPool
[folly.git] / folly / futures / FutureException.h
index 1e004dcf167a88b37a9a97762aa3b3370669244e..3e30672db3605b68ae03aa3dbbc119ba3f181167 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 #pragma once
 
-#include <exception>
+#include <stdexcept>
 #include <string>
 
 namespace folly {
 
-class FutureException : public std::exception {
-
-public:
-
-  explicit FutureException(std::string message_arg)
-    : message(message_arg) {}
-
-  ~FutureException() throw(){}
-
-  virtual const char *what() const throw() {
-    return message.c_str();
-  }
-
-  bool operator==(const FutureException &other) const{
-    return other.message == this->message;
-  }
-
-  bool operator!=(const FutureException &other) const{
-    return !(*this == other);
-  }
-
-  protected:
-    std::string message;
+class FutureException : public std::logic_error {
+ public:
+  using std::logic_error::logic_error;
 };
 
 class BrokenPromise : public FutureException {
-  public:
-    explicit BrokenPromise() :
-      FutureException("Broken promise") { }
+ public:
+  explicit BrokenPromise(const std::string& type)
+      : FutureException("Broken promise for type name `" + type + '`') {}
+
+  explicit BrokenPromise(const char* type) : BrokenPromise(std::string(type)) {}
 };
 
 class NoState : public FutureException {
 public:
-    explicit NoState() : FutureException("No state") { }
+ public:
+  NoState() : FutureException("No state") {}
 };
 
 class PromiseAlreadySatisfied : public FutureException {
-  public:
-    explicit PromiseAlreadySatisfied() :
-      FutureException("Promise already satisfied") { }
+ public:
+  PromiseAlreadySatisfied() : FutureException("Promise already satisfied") {}
 };
 
 class FutureNotReady : public FutureException {
-  public:
-    explicit FutureNotReady() :
-      FutureException("Future not ready") { }
+ public:
+  FutureNotReady() : FutureException("Future not ready") {}
 };
 
 class FutureAlreadyRetrieved : public FutureException {
-  public:
-    explicit FutureAlreadyRetrieved () :
-      FutureException("Future already retrieved") { }
-};
-
-class UsingUninitializedTry : public FutureException {
-  public:
-    explicit UsingUninitializedTry() :
-      FutureException("Using unitialized try") { }
+ public:
+  FutureAlreadyRetrieved() : FutureException("Future already retrieved") {}
 };
 
 class FutureCancellation : public FutureException {
@@ -96,4 +69,7 @@ class PredicateDoesNotObtain : public FutureException {
   PredicateDoesNotObtain() : FutureException("Predicate does not obtain") {}
 };
 
+struct NoFutureInSplitter : FutureException {
+  NoFutureInSplitter() : FutureException("No Future in this FutureSplitter") {}
+};
 }