ExceptionStrings.hpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef _EXCEPTION_STRINGS_HPP_
  14. #define _EXCEPTION_STRINGS_HPP_
  15. #include "jexcept.hpp"
  16. #include <cstring>
  17. enum eExceptionCodes
  18. {
  19. EX_STR_CAN_NOT_OPEN_XSD = 1,
  20. EX_STR_SIMPLE_TYPE_ALREADY_DEFINED,
  21. EX_STR_COMPLEX_TYPE_ALREADY_DEFINED,
  22. EX_STR_ATTRIBUTE_GROUP_ALREADY_DEFINED,
  23. EX_STR_CAN_NOT_PROCESS_ENV_XML,
  24. EX_STR_XPATH_DOES_NOT_EXIST_IN_TREE,
  25. EX_STR_MISSING_REQUIRED_ATTRIBUTE,
  26. EX_STR_MISSING_VALUE_ATTRIBUTE_IN_LENGTH,
  27. EX_STR_LENGTH_VALUE_MUST_BE_GREATER_THAN_OR_EQUAL_TO_ZERO,
  28. EX_STR_PATTERN_HAS_INVALID_VALUE,
  29. EX_STR_WHITE_SPACE_HAS_INVALID_VALUE,
  30. EX_STR_MISSING_NAME_ATTRIBUTE,
  31. EX_STR_UNKNOWN,
  32. EX_STR_LAST_ENTRY
  33. };
  34. namespace CONFIGURATOR
  35. {
  36. #define MAX_EXCEPTION_STRING_LENGTH 2048
  37. #define CATCH_EXCEPTION_AND_EXIT \
  38. catch (::IException *except) \
  39. {\
  40. StringBuffer strErrMsg;\
  41. except->errorMessage(strErrMsg);\
  42. ::std::cout << ::std::endl << strErrMsg.str() << ::std::endl << ::std::endl;\
  43. except->Release();\
  44. exit(-1);\
  45. }
  46. const char pExceptionStringArray[EX_STR_LAST_ENTRY][MAX_EXCEPTION_STRING_LENGTH] = { /*** ALWAYS ADD TO THE END OF THE ARRAY!!! ***/
  47. "can not open xsd file", //
  48. "simple type already defined",
  49. "complex type already defined",
  50. "attribute group already defined",
  51. "can not open/parse environment xml configuration",
  52. "xpath does not exist in supplied tree",
  53. "the xml file is missing a required attribute based on the xsd",
  54. "length type can not have an empty value attribute",
  55. "length value must be greater than or equal to zero",
  56. /*** ADD CORRESPONDING ENTRY TO pExceptionStringActionArray ***/
  57. };
  58. const char pExceptionStringActionArray[EX_STR_LAST_ENTRY*2][MAX_EXCEPTION_STRING_LENGTH] = { /*** ALWAYS ADD TO THE END OF THE ARRAY!!! ***/
  59. /* 1 */ "Ensure that input xsd files exist and that it's permissions are set properly",
  60. /* 2 */ "Multiple xs:simpleType tags with the same name defined in xsd files. Try processing xsd files using -use parameter and only specify 1 xsd file for processing." ,
  61. /* 3 */ "Multiple xs:complexType tags with the same name defined in xsd files. Try processing xsd files using -use parameter and only specify 1 xsd file for processing.",
  62. /* 4 */ "Multiple xs:attributeGroup tags with the same name defined in xsd files. Try processing xsd files using -use parameter and only specify 1 xsd file for processing.",
  63. /* 5 */ "Failed to open/parss specified configuration file. Verify file exits, permissions are set properly, and the file is valid.",
  64. /* 6 */ "The XML file may have errors.",
  65. /* 7 */ "The XML file may have errors. An attribute marked as required in the XSD is missing in the xml file."
  66. /* 8 */ "The XSD has an node xs:restriction type with an xs:length datatype that has not value; value is required",
  67. /* 9 */ "The XSD has an node xs:length @value is not greater than or equal to 0",
  68. /* 10 */ "The XSD has an node xs:fractionDigits that has a value that is not greater than or equl to 0",
  69. /* 11 */ "The XSD has an node xs:minLength value that is not greater than or equl to 0",
  70. /* 12 */ "The XSD has an node xs:minInclusive that has no value attribute",
  71. /* 13 */ "The XSD has an node xs:max:Exclusive that has no value attribute",
  72. /* 14 */ "The XSD has an node xs:max:Inclusive that has no value attribute",
  73. /* 15 */ "The XSD has a node xs:maxLength @value is not greater than or equal to 0",
  74. /* 16 */ "The XSD has a node xs:pattern @value is not set",
  75. /* 17 */ "The XSD has a node xs:totalDigits @value is not greater than or equal to 0",
  76. /* 18 */ "The XSD has a node xs:whitespace @value is not valid",
  77. /*** ADD CORRESPONDING ENTRY TO pExceptionStringActionArray ***/
  78. };
  79. enum eActionArray { EACTION_FRACTION_DIGITS_HAS_BAD_LENGTH = 10,
  80. EACTION_MIN_LENGTH_BAD_LENGTH = 11,
  81. EACTION_MIN_INCLUSIVE_NO_VALUE = 12,
  82. EACTION_MAX_EXCLUSIVE_NO_VALUE = 13,
  83. EACTION_MAX_INCLUSIVE_NO_VALUE = 14,
  84. EACTION_MAX_LENGTH_BAD_LENGTH = 15,
  85. EACTION_PATTERN_MISSING_VALUE = 16,
  86. EACTION_TOTAL_DIGITS_BAD_LENGTH = 17,
  87. EACTION_WHITE_SPACE_BAD_VALUE = 18
  88. };
  89. ::IException *MakeExceptionFromMap(int code, enum eExceptionCodes, const char* pMsg = NULL);
  90. ::IException *MakeExceptionFromMap(enum eExceptionCodes, const char* pMsg = NULL);
  91. }
  92. #endif // _EXCEPTION_STRINGS_HPP_