IBR-DTNSuite  0.10
Exceptions.h
Go to the documentation of this file.
1 /*
2  * Exceptions.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef EXCEPTIONS_H_
23 #define EXCEPTIONS_H_
24 
25 #include "ibrcommon/Exceptions.h"
26 
27 #include <stdexcept>
28 #include <string>
29 
30 
31 using namespace std;
32 
33 namespace dtn
34 {
39  {
40  public:
41  InvalidDataException(string what = "Invalid input data.") throw() : Exception(what)
42  {
43  };
44  };
45 
47  {
48  public:
49  InvalidProtocolException(string what = "The received data does not match the protocol.") throw() : dtn::InvalidDataException(what)
50  {
51  };
52  };
53 
55  {
56  public:
57  SerializationFailedException(string what = "The serialization failed.") throw() : dtn::InvalidDataException(what)
58  {
59  };
60  };
61 
63  {
64  public:
65  const size_t length;
66  PayloadReceptionInterrupted(const size_t l, string what = "The payload reception has been interrupted.") throw() : dtn::SerializationFailedException(what), length(l)
67  {
68  };
69  };
70 
72  {
73  public:
74  MissingObjectException(string what = "Object not available.") throw() : Exception(what)
75  {
76  };
77  };
78 
80  {
81  public:
82  ConnectionInterruptedException() : ibrcommon::IOException("The connection has been interrupted.")
83  {
84  }
85  };
86 }
87 
88 #endif /*EXCEPTIONS_H_*/