Mark the base class of NoFutureInSplitter as public
[folly.git] / folly / futures / FutureException.h
index 1e004dcf167a88b37a9a97762aa3b3370669244e..4bd2021cec299e19e3540bbf58e6708c49f1cd5a 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>
 
+#include <folly/CPortability.h>
+
 namespace folly {
 
-class FutureException : public std::exception {
+class FOLLY_EXPORT FutureException : public std::logic_error {
+ public:
+  using std::logic_error::logic_error;
+};
 
-public:
+class FOLLY_EXPORT BrokenPromise : public FutureException {
+ public:
+  explicit BrokenPromise(const std::string& type)
+      : FutureException("Broken promise for type name `" + type + '`') {}
 
-  explicit FutureException(std::string message_arg)
-    : message(message_arg) {}
+  explicit BrokenPromise(const char* type) : BrokenPromise(std::string(type)) {}
+};
 
-  ~FutureException() throw(){}
+class FOLLY_EXPORT NoState : public FutureException {
+ public:
+  NoState() : FutureException("No state") {}
+};
 
-  virtual const char *what() const throw() {
-    return message.c_str();
-  }
+[[noreturn]] void throwNoState();
 
-  bool operator==(const FutureException &other) const{
-    return other.message == this->message;
-  }
+class FOLLY_EXPORT PromiseAlreadySatisfied : public FutureException {
+ public:
+  PromiseAlreadySatisfied() : FutureException("Promise already satisfied") {}
+};
 
-  bool operator!=(const FutureException &other) const{
-    return !(*this == other);
-  }
+[[noreturn]] void throwPromiseAlreadySatisfied();
 
-  protected:
-    std::string message;
+class FOLLY_EXPORT FutureNotReady : public FutureException {
+ public:
+  FutureNotReady() : FutureException("Future not ready") {}
 };
 
-class BrokenPromise : public FutureException {
-  public:
-    explicit BrokenPromise() :
-      FutureException("Broken promise") { }
-};
+[[noreturn]] void throwFutureNotReady();
 
-class NoState : public FutureException {
 public:
-    explicit NoState() : FutureException("No state") { }
+class FOLLY_EXPORT FutureAlreadyRetrieved : public FutureException {
+ public:
+  FutureAlreadyRetrieved() : FutureException("Future already retrieved") {}
 };
 
-class PromiseAlreadySatisfied : public FutureException {
-  public:
-    explicit PromiseAlreadySatisfied() :
-      FutureException("Promise already satisfied") { }
-};
+[[noreturn]] void throwFutureAlreadyRetrieved();
 
-class FutureNotReady : public FutureException {
-  public:
-    explicit FutureNotReady() :
-      FutureException("Future not ready") { }
+class FOLLY_EXPORT FutureCancellation : public FutureException {
+ public:
+  FutureCancellation() : FutureException("Future was cancelled") {}
 };
 
-class FutureAlreadyRetrieved : public FutureException {
-  public:
-    explicit FutureAlreadyRetrieved () :
-      FutureException("Future already retrieved") { }
+class FOLLY_EXPORT TimedOut : public FutureException {
+ public:
+  TimedOut() : FutureException("Timed out") {}
 };
 
-class UsingUninitializedTry : public FutureException {
-  public:
-    explicit UsingUninitializedTry() :
-      FutureException("Using unitialized try") { }
-};
+[[noreturn]] void throwTimedOut();
 
-class FutureCancellation : public FutureException {
+class FOLLY_EXPORT PredicateDoesNotObtain : public FutureException {
  public:
-  FutureCancellation() : FutureException("Future was cancelled") {}
+  PredicateDoesNotObtain() : FutureException("Predicate does not obtain") {}
 };
 
-class TimedOut : public FutureException {
+[[noreturn]] void throwPredicateDoesNotObtain();
+
+class FOLLY_EXPORT NoFutureInSplitter : public FutureException {
  public:
-  TimedOut() : FutureException("Timed out") {}
+  NoFutureInSplitter() : FutureException("No Future in this FutureSplitter") {}
 };
 
-class PredicateDoesNotObtain : public FutureException {
+[[noreturn]] void throwNoFutureInSplitter();
+
+class FOLLY_EXPORT NoTimekeeper : public FutureException {
  public:
-  PredicateDoesNotObtain() : FutureException("Predicate does not obtain") {}
+  NoTimekeeper() : FutureException("No timekeeper available") {}
 };
 
-}
+[[noreturn]] void throwNoExecutor();
+
+class FOLLY_EXPORT NoExecutor : public FutureException {
+ public:
+  NoExecutor() : FutureException("No executor provided to via") {}
+};
+} // namespace folly