libdigidocpp
Exception.h
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 #pragma once
21 
22 #include "Exports.h"
23 
24 #include <string>
25 #include <vector>
26 
27 namespace digidoc
28 {
37  {
38  public:
43  CertificateIssuerMissing = 10,
44  CertificateRevoked = 5,
45  CertificateUnknown = 6,
46  NoException = 0,
47  OCSPResponderMissing = 8,
48  OCSPCertMissing = 9,
49  OCSPTimeSlot = 7,
50  OCSPRequestUnauthorized = 11,
51  PINCanceled = 2,
52  PINFailed = 4,
53  PINIncorrect = 1,
54  PINLocked = 3,
55  };
56  typedef std::vector<Exception> Causes;
57 
58  Exception(const std::string& file, int line, const std::string& msg);
59  Exception(const std::string& file, int line, const std::string& msg, const Exception& cause);
60  ExceptionCode code() const;
61  int ddoc() const;
62  std::string getMsg() const;
63  bool hasCause() const;
64  Causes getCauses() const;
65  void addCause(const Exception& cause);
66  void setCode( ExceptionCode Code );
67  void setDDoc( int err );
68 
69  protected:
70  std::string file;
71  std::string msg;
72  int line;
73  int m_ddoc;
76  };
77 
85  {
86  public:
87  BDocException(const std::string& file, int line, const std::string& msg);
88  BDocException(const std::string& file, int line, const std::string& msg, const Exception& cause);
89  };
90 
97  {
98  public:
99  IOException(const std::string& file, int line, const std::string& msg);
100  IOException(const std::string& file, int line, const std::string& msg, const Exception& cause);
101  };
102 
109  {
110  public:
111  SignException(const std::string& file, int line, const std::string& msg);
112  SignException(const std::string& file, int line, const std::string& msg, const Exception& cause);
113  };
114 
122  {
123  public:
124  SignatureException(const std::string& file, int line, const std::string& msg);
125  SignatureException(const std::string& file, int line, const std::string& msg, const Exception& cause);
126  };
127 }