(Wangle) Sanity check for the small_vector test
[folly.git] / folly / wangle / WangleException.h
1 /*
2  * Copyright 2014 Facebook, Inc.
3  *
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
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #pragma once
18
19 #include <exception>
20
21 namespace folly { namespace wangle {
22
23 class WangleException : public std::exception {
24
25 public:
26
27   explicit WangleException(std::string message_arg)
28     : message(message_arg) {}
29
30   ~WangleException() throw(){}
31
32   virtual const char *what() const throw() {
33     return message.c_str();
34   }
35
36   bool operator==(const WangleException &other) const{
37     return other.message == this->message;
38   }
39
40   bool operator!=(const WangleException &other) const{
41     return !(*this == other);
42   }
43
44   protected:
45     std::string message;
46 };
47
48 class BrokenPromise : public WangleException {
49   public:
50     explicit BrokenPromise() :
51       WangleException("Broken promise") { }
52 };
53
54 class NoState : public WangleException {
55   public:
56     explicit NoState() : WangleException("No state") { }
57 };
58
59 class PromiseAlreadySatisfied : public WangleException {
60   public:
61     explicit PromiseAlreadySatisfied() :
62       WangleException("Promise already satisfied") { }
63 };
64
65 class FutureAlreadyRetrieved : public WangleException {
66   public:
67     explicit FutureAlreadyRetrieved () :
68       WangleException("Future already retrieved") { }
69 };
70
71 class UsingUninitializedTry : public WangleException {
72   public:
73     explicit UsingUninitializedTry() :
74       WangleException("Using unitialized try") { }
75 };
76
77 }}