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