2 * Copyright 2017 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.
22 #include <folly/CPortability.h>
26 class FOLLY_EXPORT FutureException : public std::logic_error {
28 using std::logic_error::logic_error;
31 class FOLLY_EXPORT BrokenPromise : public FutureException {
33 explicit BrokenPromise(const std::string& type)
34 : FutureException("Broken promise for type name `" + type + '`') {}
36 explicit BrokenPromise(const char* type) : BrokenPromise(std::string(type)) {}
39 class FOLLY_EXPORT NoState : public FutureException {
41 NoState() : FutureException("No state") {}
44 [[noreturn]] void throwNoState();
46 class FOLLY_EXPORT PromiseAlreadySatisfied : public FutureException {
48 PromiseAlreadySatisfied() : FutureException("Promise already satisfied") {}
51 [[noreturn]] void throwPromiseAlreadySatisfied();
53 class FOLLY_EXPORT FutureNotReady : public FutureException {
55 FutureNotReady() : FutureException("Future not ready") {}
58 [[noreturn]] void throwFutureNotReady();
60 class FOLLY_EXPORT FutureAlreadyRetrieved : public FutureException {
62 FutureAlreadyRetrieved() : FutureException("Future already retrieved") {}
65 [[noreturn]] void throwFutureAlreadyRetrieved();
67 class FOLLY_EXPORT FutureCancellation : public FutureException {
69 FutureCancellation() : FutureException("Future was cancelled") {}
72 class FOLLY_EXPORT TimedOut : public FutureException {
74 TimedOut() : FutureException("Timed out") {}
77 [[noreturn]] void throwTimedOut();
79 class FOLLY_EXPORT PredicateDoesNotObtain : public FutureException {
81 PredicateDoesNotObtain() : FutureException("Predicate does not obtain") {}
84 [[noreturn]] void throwPredicateDoesNotObtain();
86 class FOLLY_EXPORT NoFutureInSplitter : FutureException {
88 NoFutureInSplitter() : FutureException("No Future in this FutureSplitter") {}
91 [[noreturn]] void throwNoFutureInSplitter();
93 class FOLLY_EXPORT NoTimekeeper : public FutureException {
95 NoTimekeeper() : FutureException("No timekeeper available") {}