You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

exceptions.py 5.0 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Copyright 2019 Huawei Technologies Co., Ltd
  2. #
  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. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Definition of error code and relative messages in lineage module."""
  16. from mindinsight.utils.exceptions import MindInsightException
  17. from mindinsight.lineagemgr.common.exceptions.error_code import LineageErrors, LineageErrorMsg
  18. class LineageParamTypeError(MindInsightException):
  19. """The parameter type error in lineage module."""
  20. def __init__(self, msg):
  21. super(LineageParamTypeError, self).__init__(
  22. error=LineageErrors.PARAM_TYPE_ERROR,
  23. message=LineageErrorMsg.PARAM_TYPE_ERROR.value.format(msg),
  24. http_code=400
  25. )
  26. class LineageParamValueError(MindInsightException):
  27. """The parameter value error in lineage module."""
  28. def __init__(self, msg):
  29. super(LineageParamValueError, self).__init__(
  30. error=LineageErrors.PARAM_VALUE_ERROR,
  31. message=LineageErrorMsg.PARAM_VALUE_ERROR.value.format(msg),
  32. http_code=400
  33. )
  34. class LineageSummaryAnalyzeException(MindInsightException):
  35. """The summary analyze error in lineage module."""
  36. def __init__(self, msg=None):
  37. if msg is None:
  38. msg = ''
  39. super(LineageSummaryAnalyzeException, self).__init__(
  40. error=LineageErrors.SUMMARY_ANALYZE_ERROR,
  41. message=LineageErrorMsg.SUMMARY_ANALYZE_ERROR.value.format(msg),
  42. http_code=400
  43. )
  44. class LineageVerificationException(MindInsightException):
  45. """The summary verification error in lineage module."""
  46. def __init__(self, msg):
  47. super(LineageVerificationException, self).__init__(
  48. error=LineageErrors.SUMMARY_VERIFICATION_ERROR,
  49. message=LineageErrorMsg.SUMMARY_VERIFICATION_ERROR.value.format(msg),
  50. http_code=400
  51. )
  52. class LineageEventNotExistException(MindInsightException):
  53. """The querier error in lineage module."""
  54. def __init__(self):
  55. super(LineageEventNotExistException, self).__init__(
  56. error=LineageErrors.EVENT_NOT_EXIST_ERROR,
  57. message=LineageErrorMsg.EVENT_NOT_EXIST_ERROR.value,
  58. http_code=400
  59. )
  60. class LineageQuerierParamException(MindInsightException):
  61. """The querier error in lineage module."""
  62. def __init__(self, *msg):
  63. super(LineageQuerierParamException, self).__init__(
  64. error=LineageErrors.QUERIER_PARAM_ERROR,
  65. message=LineageErrorMsg.QUERIER_PARAM_ERROR.value.format(*msg),
  66. http_code=400
  67. )
  68. class LineageSummaryParseException(MindInsightException):
  69. """The querier error in lineage module."""
  70. def __init__(self):
  71. super(LineageSummaryParseException, self).__init__(
  72. error=LineageErrors.SUMMARY_PARSE_FAIL_ERROR,
  73. message=LineageErrorMsg.SUMMARY_PARSE_FAIL_ERROR.value,
  74. http_code=400
  75. )
  76. class LineageEventFieldNotExistException(MindInsightException):
  77. """The querier error in lineage module."""
  78. def __init__(self, msg):
  79. super(LineageEventFieldNotExistException, self).__init__(
  80. error=LineageErrors.EVENT_FIELD_NOT_EXIST_ERROR,
  81. message=LineageErrorMsg.EVENT_FIELD_NOT_EXIST_ERROR.value.format(msg),
  82. http_code=400
  83. )
  84. class LineageQuerySummaryDataError(MindInsightException):
  85. """Query summary data error in lineage module."""
  86. def __init__(self, msg):
  87. super(LineageQuerySummaryDataError, self).__init__(
  88. error=LineageErrors.LINEAGE_SUMMARY_DATA_ERROR,
  89. message=LineageErrorMsg.LINEAGE_SUMMARY_DATA_ERROR.value.format(msg),
  90. http_code=400
  91. )
  92. class LineageFileNotFoundError(MindInsightException):
  93. """Summary file not found in lineage module."""
  94. def __init__(self, msg):
  95. super(LineageFileNotFoundError, self).__init__(
  96. error=LineageErrors.LINEAGE_FILE_NOT_FOUND_ERROR,
  97. message=LineageErrorMsg.LINEAGE_FILE_NOT_FOUND_ERROR.value.format(msg),
  98. http_code=400
  99. )
  100. class LineageSearchConditionParamError(MindInsightException):
  101. """Search condition param is invalid in lineage module."""
  102. def __init__(self, msg):
  103. super(LineageSearchConditionParamError, self).__init__(
  104. error=LineageErrors.LINEAGE_SEARCH_CONDITION_PARAM_ERROR,
  105. message=LineageErrorMsg.LINEAGE_SEARCH_CONDITION_PARAM_ERROR.value.format(msg),
  106. http_code=400
  107. )