Separatista
exception.h
1 /***************************************************************************
2 * Copyright (C) 2014 by Okkel Klaver *
3 * info@vanhetland.nl *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 
21 #ifndef SEPARATISTA_EXCEPTION_H
22 #define SEPARATISTA_EXCEPTION_H
23 
24 #include <string>
25 
26 #include "separatista.h"
27 
28 #ifdef SEPARATISTA_DEBUG
29 # define SEPARATISTA_THROW_EXCEPTION(type, msg, ...) throw type(msg, TEXT(__FILE__), __LINE__, __VA_ARGS__)
30 #else
31 # define SEPARATISTA_THROW_EXCEPTION(type, msg, ...) throw type(msg, __VA_ARGS__)
32 #endif // defined SEPARATISTA_DEBUG
33 
34 #define SEPARATISTA_REPORT(e) LOG(e.getMessage())
35 
36 namespace Separatista
37 {
38  class Element;
39 
40  class SEPARATISTA_EXTERN Exception
41  {
42  public:
43  Exception(const wchar_t *pMessage);
44 #ifdef SEPARATISTA_DEBUG
45  Exception(const wchar_t *pMessage, const wchar_t *pPath, int line);
46 
47 #endif
48  const wchar_t* getMessage() const;
49 
50  protected:
51  void setMessage(const wchar_t *pMessage);
52  private:
53  std::wstring m_msg;
54  };
55 
56 
58  class SEPARATISTA_EXTERN ElementException : public Exception
59  {
60  public:
61  ElementException(const wchar_t *pMessage, const Element *pSource);
62 
63 #ifdef SEPARATISTA_DEBUG
64  ElementException(const wchar_t *pMessage, const wchar_t *pPath, int nLine, const Element *pSource);
65 #endif
66 
68  const Element* getSourceElement() const;
69 
70  private:
71  const Element *m_pSource;
72  };
73 
75  class SEPARATISTA_EXTERN UnsupportedTagException : public ElementException
76  {
77  public:
78  UnsupportedTagException(const wchar_t *pMessage, const Element *pSource, const wchar_t *pTag);
79 
80 #ifdef SEPARATISTA_DEBUG
81  UnsupportedTagException(const wchar_t *pMessage, const wchar_t *pPath, int nLine, const Element *pSource, const wchar_t *pTag);
82 #endif
83  const wchar_t* getTag() const;
85 
86  private:
87  std::wstring m_Tag;
88  };
89 
92  {
93  public:
94  UnsupportedNamespaceException(const wchar_t *pMessage, const Element *pSource, const wchar_t *pNamespace);
95 
96 #ifdef SEPARATISTA_DEBUG
97  UnsupportedNamespaceException(const wchar_t *pMessage, const wchar_t *pPath, int nLine, const Element *pSource, const wchar_t *pNamespace);
98 #endif
99  const wchar_t* getNamespace() const;
101 
102  private:
103  std::wstring m_Namespace;
104  };
105 }
106 #endif // !defined SEPARATISTA_EXCEPTION_H
Definition: exception.h:40
Definition: element.h:75
Element exception, thrown when an element method called doesn&#39;t belong to the element type...
Definition: exception.h:58
Unsupported namespace exception, thrown when the namespace isn&#39;t supported.
Definition: exception.h:91
Definition: mt940s.h:39
Definition: element.h:55
Unsupported tag exception, thrown when CreateElementByTag doesn&#39;t support the tag.
Definition: exception.h:75