commonlib
xml_exception.h
Go to the documentation of this file.
1 
11 #pragma once
12 #include <exception>
13 #include "serialization.h"
14 
15 BEGIN_NAMESPACE_SERIALIZATION
16 
20 enum class XmlExceptionCode
21 {
22  xecNodeDoesNotContainExpectedType,
23  xecNodeDoesNotExist,
24  xecDCOMIndexValueSizeIsNotSupported,
25  xecDCOMValueSizeForWrittingIsNotSupported,
26  xecValueIsOutOfRange,
27  xecInnerNodeIsNotInitialized,
28  xecDCOMDocumentIsNotSet,
29  xecNodeInFunctionArgumentIsNullptr,
30  xecDocumentInFunctionArgumentIsNullptr,
31  xecFileNameIsNotSet,
32  xecFailureWhenOpeningAFile,
33  xecFailureWhenReadingABufferFromAFile,
34  xecFailureWhenParsingXmlFile,
35  xecParameterIsADummyNode
36 };
37 
42 class XmlException : public std::exception
43 {
44 public:
45 
49  explicit XmlException(XmlExceptionCode xmlExceptionCode)
50  {
51  this->xmlExceptionCode = xmlExceptionCode;
52  }
53 
54  const char* what() const throw()
55  {
56  switch (this->xmlExceptionCode)
57  {
58  case XmlExceptionCode::xecParameterIsADummyNode:
59  return "Parameter is a dummy node!";
60  case XmlExceptionCode::xecNodeDoesNotContainExpectedType:
61  return "Node does not contain expected type!";
62  case XmlExceptionCode::xecNodeDoesNotExist:
63  return "Node you want to read does not exist!";
64  case XmlExceptionCode::xecValueIsOutOfRange:
65  return "Value is out of range!";
66  case XmlExceptionCode::xecInnerNodeIsNotInitialized:
67  return "Inner node is not initialized!";
68  case XmlExceptionCode::xecDCOMDocumentIsNotSet:
69  return "DCOM document is not set!";
70  case XmlExceptionCode::xecNodeInFunctionArgumentIsNullptr:
71  return "Node in function argument is nullptr!";
72  case XmlExceptionCode::xecDocumentInFunctionArgumentIsNullptr:
73  return "Document in function argument is nullptr!";
74  case XmlExceptionCode::xecFileNameIsNotSet:
75  return "File name is not set!";
76  case XmlExceptionCode::xecFailureWhenOpeningAFile:
77  return "Failure when opening a file!";
78  case XmlExceptionCode::xecFailureWhenReadingABufferFromAFile:
79  return "Failure when reading a buffer from a file!";
80  case XmlExceptionCode::xecFailureWhenParsingXmlFile:
81  return "Failure when parsing Xml file!";
82  case XmlExceptionCode::xecDCOMIndexValueSizeIsNotSupported:
83  return "DCOM index size is limited to values of long type!";
84  case XmlExceptionCode::xecDCOMValueSizeForWrittingIsNotSupported:
85  return "Values you can write to DCOM node are limited to values of long type!";
86  default:
87  return "XmlExceptionCode is not set!";
88  }
89  }
90 
91  XmlExceptionCode getXmlExceptionCode() const
92  {
93  return xmlExceptionCode;
94  }
95 
96 private:
97  XmlExceptionCode xmlExceptionCode;
98 };
99 
100 END_NAMESPACE_SERIALIZATION
101 
102 
XmlException(XmlExceptionCode xmlExceptionCode)
Constructor that sets an XmlExceptionCode.
Definition: xml_exception.h:49
XmlException class that inherits from std::exception and is used for exception handling in xml serial...
Definition: xml_exception.h:42
XmlExceptionCode
enums for exception types
Definition: xml_exception.h:20