libdigidocpp
Exception.cpp
Go to the documentation of this file.
1 /*
2  * libdigidocpp
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #include "Exception.h"
21 
22 #include "log.h"
23 
24 using namespace digidoc;
25 
31 Exception::Exception(const std::string& file, int line, const std::string& msg)
32  : file(file)
33  , msg(msg)
34  , line(line)
35  , m_ddoc(-1)
36  , m_code(NoException)
37 {
38  DEBUG2(file.c_str(), line, msg.c_str());
39 }
40 
51 Exception::Exception(const std::string& file, int line, const std::string& msg, const Exception& cause)
52  : file(file)
53  , msg(msg)
54  , line(line)
55  , m_ddoc(-1)
56  , m_code(NoException)
57 {
58  DEBUG2(file.c_str(), line, msg.c_str());
59  addCause(cause);
60 }
61 
66 
70 int Exception::ddoc() const { return m_ddoc; }
71 
75 std::string Exception::getMsg() const { return msg; }
76 
77 void Exception::addCause(const Exception& cause) { causes.push_back(cause); }
78 
82 bool Exception::hasCause() const { return !causes.empty(); }
83 
91 
96 
100 void Exception::setDDoc( int err ) { m_ddoc = err; }
101 
108 digidoc::BDocException::BDocException(const std::string& file, int line, const std::string& msg)
109  : Exception(file, line, msg)
110 {}
111 
121 digidoc::BDocException::BDocException(const std::string& file, int line, const std::string& msg, const Exception& cause)
122 : Exception(file, line, msg, cause)
123 {}
124 
131 digidoc::IOException::IOException(const std::string& file, int line, const std::string& msg)
132  : Exception(file, line, msg)
133 {}
134 
144 digidoc::IOException::IOException(const std::string& file, int line, const std::string& msg, const Exception& cause)
145 : Exception(file, line, msg, cause)
146 {}
147 
154 digidoc::SignException::SignException(const std::string& file, int line, const std::string& msg)
155  : Exception(file, line, msg)
156 {}
157 
167 digidoc::SignException::SignException(const std::string& file, int line, const std::string& msg, const Exception& cause)
168 : Exception(file, line, msg, cause)
169 {}
170 
177 digidoc::SignatureException::SignatureException(const std::string& file, int line, const std::string& msg)
178  : Exception(file, line, msg)
179 {}
180 
190 digidoc::SignatureException::SignatureException(const std::string& file, int line, const std::string& msg, const Exception& cause)
191 : Exception(file, line, msg, cause)
192 {}