LayoutException.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #include "LayoutException.h"
  2. LayoutException::LayoutException(QString sFunctionName, LayoutExceptionEnum::LayoutExceptionTypes enExceptionType)
  3. {
  4. m_enExceptionType = enExceptionType;
  5. m_sExceptionFunctionName = sFunctionName;
  6. m_enExceptionSubType = LayoutExceptionEnum::UNKNOWNLAYOUTEXCEPTION;
  7. }
  8. LayoutException::LayoutException(QString sFunctionName,
  9. LayoutExceptionEnum::LayoutExceptionSubTypes enLayoutExceptionSubType)
  10. {
  11. m_enExceptionType = LayoutExceptionEnum::LAYOUTEXCEPTION;
  12. m_sExceptionFunctionName = sFunctionName;
  13. m_enExceptionSubType = enLayoutExceptionSubType;
  14. }
  15. LayoutException::LayoutException(QString sFunctionName,
  16. LayoutExceptionEnum::LayoutExceptionSubTypes enLayoutExceptionSubType,
  17. QString sEntityValue,
  18. QString sEntityType)
  19. {
  20. m_enExceptionType = LayoutExceptionEnum::LAYOUTEXCEPTION;
  21. m_sExceptionFunctionName = sFunctionName;
  22. m_enExceptionSubType = enLayoutExceptionSubType;
  23. m_sEntityValue = sEntityValue;
  24. m_sEntityType = sEntityType;
  25. QString sErrorMessage = this->constructMessageForExceptionSubType();
  26. this->setErrorMessage(sErrorMessage);
  27. }
  28. LayoutException::LayoutException(QString sFunctionName,
  29. LayoutExceptionEnum::LayoutExceptionSubTypes enLayoutExceptionSubType,
  30. QString sEntityValue,
  31. QString sEntityType,
  32. QString sAttributeName,
  33. QString sAttributeValue)
  34. {
  35. m_enExceptionType = LayoutExceptionEnum::LAYOUTEXCEPTION;
  36. m_sExceptionFunctionName = sFunctionName;
  37. m_enExceptionSubType = enLayoutExceptionSubType;
  38. m_sEntityValue = sEntityValue;
  39. m_sEntityType = sEntityType;
  40. m_sAttributeName = sAttributeName;
  41. m_sAttributeValue = sAttributeValue;
  42. QString sErrorMessage = this->constructMessageForExceptionSubType();
  43. this->setErrorMessage(sErrorMessage);
  44. }
  45. LayoutException::~LayoutException() throw()
  46. {
  47. }
  48. QString LayoutException::constructMessageForExceptionSubType()
  49. {
  50. QString sErrorMessage = " ";
  51. switch(m_enExceptionSubType)
  52. {
  53. case LayoutExceptionEnum::INVALID_PARAMETER:
  54. {
  55. sErrorMessage = LAYOUTEXCEPTION_INVALID_PARAMETER_MESSAGE;
  56. sErrorMessage = sErrorMessage.arg(m_sEntityType, m_sEntityValue);
  57. }
  58. break;
  59. case LayoutExceptionEnum::DUPLICATE_ID:
  60. {
  61. sErrorMessage = LAYOUTEXCEPTION_DUPLICATE_ID_FOUND_MESSAGE;
  62. sErrorMessage = sErrorMessage.arg(m_sEntityId, m_sEntityType);
  63. }
  64. break;
  65. case LayoutExceptionEnum::INVALID_ATTRIBUTE_VALUE:
  66. {
  67. sErrorMessage = LAYOUTEXCEPTION_INVALID_ATTRIBUTE_VALUE_MESAAGE;
  68. sErrorMessage = sErrorMessage.arg(m_sEntityType, m_sAttributeName, m_sAttributeValue);
  69. }
  70. break;
  71. case LayoutExceptionEnum::MANDATORY_FIELD_MISSING:
  72. {
  73. sErrorMessage = LAYOUTEXCEPTION_MANDATORY_ATTRIBUTE_MISSING_MESSAGE;
  74. sErrorMessage = sErrorMessage.arg(m_sAttributeName,m_sEntityType);
  75. }
  76. break;
  77. case LayoutExceptionEnum::EMPTY_CONTAINER:
  78. {
  79. sErrorMessage == LAYOUTEXCEPTION_EMPTY_CONTAINER_FOUND_MESSAGE;
  80. sErrorMessage = sErrorMessage.arg(m_sEntityType);
  81. }
  82. break;
  83. case LayoutExceptionEnum::INVALID_TYPE:
  84. {
  85. sErrorMessage = LAYOUTEXCEPTION_INVALID_TYPE_MESSAGE;
  86. sErrorMessage = sErrorMessage.arg(m_sEntityValue);
  87. }
  88. break;
  89. case LayoutExceptionEnum::REQUIRED_PARAMETER_NOT_SET:
  90. {
  91. sErrorMessage = LAYOUTEXCEPTION_REQUIRED_PARAMETER_NOT_SET_MESSAGE;
  92. sErrorMessage = sErrorMessage.arg(m_sEntityValue);
  93. }
  94. break;
  95. case LayoutExceptionEnum::NOT_FOUND_IN_CONTAINER:
  96. {
  97. sErrorMessage = LAYOUTEXCEPTION_NOT_FOUND_IN_CONTAINER_MESSAGE;
  98. sErrorMessage = sErrorMessage.arg(m_sEntityType, m_sEntityValue);
  99. }
  100. break;
  101. case LayoutExceptionEnum::INVALID_OPERATION:
  102. {
  103. sErrorMessage = LAYOUTEXCEPTION_INVALID_OPERATION_MESSAGE;
  104. sErrorMessage = sErrorMessage.arg(m_sEntityValue , m_sEntityType);
  105. }
  106. break;
  107. case LayoutExceptionEnum::INCONSISTENT_DATASTRUCTURE:
  108. {
  109. sErrorMessage = LAYOUTEXCEPTION_INCONSISTENT_DATASTRUCTURE_MESSAGE;
  110. sErrorMessage = sErrorMessage.arg(m_sEntityType, m_sEntityValue);
  111. }
  112. break;
  113. case LayoutExceptionEnum::INVALID_GRAPH_TYPE:
  114. {
  115. sErrorMessage = LAYOUTEXCEPTION_INVALID_GRAPH_TYPE_MESSAGE;
  116. sErrorMessage = sErrorMessage.arg(m_sEntityValue, m_sEntityType);
  117. }
  118. break;
  119. default:
  120. sErrorMessage = LAYOUTEXCEPTION_UNKNOWN_EXCEPTION_MESSAGE;
  121. break;
  122. }
  123. return sErrorMessage;
  124. }
  125. void LayoutException::setExceptionType(LayoutExceptionEnum::LayoutExceptionTypes enExceptionType)
  126. {
  127. m_enExceptionType = enExceptionType;
  128. }
  129. void LayoutException::setErrorMessage(QString sErrorMessage)
  130. {
  131. m_sErrorMessage = sErrorMessage;
  132. }
  133. void LayoutException::setExceptionFunctionName(QString sFunctionName)
  134. {
  135. m_sExceptionFunctionName = sFunctionName;
  136. }
  137. unsigned int LayoutException::getExceptionType()
  138. {
  139. return m_enExceptionType;
  140. }
  141. QString LayoutException::getErrorMessage()
  142. {
  143. return m_sErrorMessage;
  144. }
  145. QString LayoutException::getExceptionFunctionName()
  146. {
  147. return m_sExceptionFunctionName;
  148. }
  149. int LayoutException::getErrorCode()
  150. {
  151. return m_enExceptionSubType;
  152. }
  153. QString LayoutException::getEntityValue()
  154. {
  155. return m_sEntityValue;
  156. }
  157. QString LayoutException::getEntityType()
  158. {
  159. return m_sEntityType;
  160. }
  161. LayoutExceptionEnum::LayoutExceptionSubTypes LayoutException::getExceptionSubType()
  162. {
  163. return m_enExceptionSubType;
  164. }
  165. LayoutException::LayoutException()
  166. {
  167. }