1 // -*- C++ -*-
2 /*****************************************************************************\
3  * Copyright (c) 2004 Mark Aylett <mark@emantic.co.uk>                       *
4  *                                                                           *
5  * Permission is hereby granted, free of charge, to any person obtaining a   *
6  * copy of this software and associated documentation files (the             *
7  * "Software"), to deal in the Software without restriction, including       *
8  * without limitation the rights to use, copy, modify, merge, publish,       *
9  * distribute, sublicense, and/or sell copies of the Software, and to permit *
10  * persons to whom the Software is furnished to do so, subject to the        *
11  * following conditions:                                                     *
12  *                                                                           *
13  * The above copyright notice and this permission notice shall be included   *
14  * in all copies or substantial portions of the Software.                    *
15  *                                                                           *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS   *
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF                *
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN *
19  * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,  *
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR     *
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
22  * USE OR OTHER DEALINGS IN THE SOFTWARE.                                    *
23 \*****************************************************************************/
24 
25 /**
26  * \file mar_exception_cpp.h
27  * \brief TODO
28  */
29 
30 #ifndef INCLUDED_MAR_EXCEPTION_CPP
31 #define INCLUDED_MAR_EXCEPTION_CPP
32 
33 #ifndef INCLUDED_MAR_DEFS_CPP
34 #include "mar_defs_cpp.h"
35 #endif // INCLUDED_MAR_DEFS_CPP
36 
37 #ifndef INCLUDED_MAR_C
38 #include "mar_c.h"
39 #endif // INCLUDED_MAR_C
40 
41 #ifndef INCLUDED_CSTRING
42 #define INCLUDED_CSTRING
43 #include <cstring>
44 #endif // INCLUDED_CSTRING
45 
46 #ifndef INCLUDED_EXCEPTION
47 #define INCLUDED_EXCEPTION
48 #include <exception>
49 #endif // INCLUDED_EXCEPTION
50 
51 namespace mar {
52 
53     class error
54         : public std::exception {
55         int num_;
56     public:
error()57         error()
58             : num_(mar_errno())
59         {
60         }
61         explicit
error(int n)62         error(int n)
63             : num_(n)
64         {
65         }
66         const char*
what()67         what() const MAR_NOTHROW
68         {
69             return strerror(num_);
70         }
71         int
num()72         num() const MAR_NOTHROW
73         {
74             return num_;
75         }
76     };
77 }
78 
79 #endif // INCLUDED_MAR_EXCEPTION_CPP
80