2 * Copyright 2016 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 class FutureException : public std::exception {
28 explicit FutureException(std::string message_arg)
29 : message(message_arg) {}
31 ~FutureException() throw(){}
33 virtual const char *what() const throw() {
34 return message.c_str();
37 bool operator==(const FutureException &other) const{
38 return other.message == this->message;
41 bool operator!=(const FutureException &other) const{
42 return !(*this == other);
49 class BrokenPromise : public FutureException {
51 explicit BrokenPromise(std::string type) :
53 (std::string("Broken promise for type name `") + type) + '`') { }
56 class NoState : public FutureException {
58 explicit NoState() : FutureException("No state") { }
61 class PromiseAlreadySatisfied : public FutureException {
63 explicit PromiseAlreadySatisfied() :
64 FutureException("Promise already satisfied") { }
67 class FutureNotReady : public FutureException {
69 explicit FutureNotReady() :
70 FutureException("Future not ready") { }
73 class FutureAlreadyRetrieved : public FutureException {
75 explicit FutureAlreadyRetrieved () :
76 FutureException("Future already retrieved") { }
79 class FutureCancellation : public FutureException {
81 FutureCancellation() : FutureException("Future was cancelled") {}
84 class TimedOut : public FutureException {
86 TimedOut() : FutureException("Timed out") {}
89 class PredicateDoesNotObtain : public FutureException {
91 PredicateDoesNotObtain() : FutureException("Predicate does not obtain") {}