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 8.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. # Copyright 2020 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 profiler module."""
  16. from mindinsight.profiler.common.exceptions.error_code import ProfilerErrors, \
  17. ProfilerErrorMsg
  18. from mindinsight.utils.exceptions import MindInsightException
  19. class ProfilerParamValueErrorException(MindInsightException):
  20. """The parameter value error in profiler module."""
  21. def __init__(self, msg):
  22. super(ProfilerParamValueErrorException, self).__init__(
  23. error=ProfilerErrors.PARAM_VALUE_ERROR,
  24. message=ProfilerErrorMsg.PARAM_VALUE_ERROR.value.format(msg),
  25. http_code=400
  26. )
  27. class ProfilerPathErrorException(MindInsightException):
  28. """The path error in profiler module."""
  29. def __init__(self, msg):
  30. super(ProfilerPathErrorException, self).__init__(
  31. error=ProfilerErrors.PATH_ERROR,
  32. message=ProfilerErrorMsg.PATH_ERROR.value.format(msg),
  33. http_code=400
  34. )
  35. class ProfilerParamTypeErrorException(MindInsightException):
  36. """The parameter type error in profiler module."""
  37. def __init__(self, msg):
  38. super(ProfilerParamTypeErrorException, self).__init__(
  39. error=ProfilerErrors.PARAM_TYPE_ERROR,
  40. message=ProfilerErrorMsg.PARAM_TYPE_ERROR.value.format(msg),
  41. http_code=400
  42. )
  43. class ProfilerDirNotFoundException(MindInsightException):
  44. """The dir not found exception in profiler module."""
  45. def __init__(self, msg):
  46. super(ProfilerDirNotFoundException, self).__init__(
  47. error=ProfilerErrors.DIR_NOT_FOUND_ERROR,
  48. message=ProfilerErrorMsg.DIR_NOT_FOUND_ERROR.value.format(msg),
  49. http_code=400
  50. )
  51. class ProfilerFileNotFoundException(MindInsightException):
  52. """The file not found exception in profiler module."""
  53. def __init__(self, msg):
  54. super(ProfilerFileNotFoundException, self).__init__(
  55. error=ProfilerErrors.FILE_NOT_FOUND_ERROR,
  56. message=ProfilerErrorMsg.FILE_NOT_FOUND_ERROR.value.format(msg),
  57. http_code=400
  58. )
  59. class ProfilerIOException(MindInsightException):
  60. """The IO exception in profiler module."""
  61. def __init__(self):
  62. super(ProfilerIOException, self).__init__(
  63. error=ProfilerErrors.IO_ERROR,
  64. message=ProfilerErrorMsg.IO_ERROR.value,
  65. http_code=400
  66. )
  67. class ProfilerDeviceIdMismatchException(MindInsightException):
  68. """The device id mismatch exception in profiler module."""
  69. def __init__(self):
  70. super(ProfilerDeviceIdMismatchException, self).__init__(
  71. error=ProfilerErrors.DEVICE_ID_MISMATCH_ERROR,
  72. message=ProfilerErrorMsg.DEVICE_ID_MISMATCH_ERROR.value,
  73. http_code=400
  74. )
  75. class ProfilerRawFileException(MindInsightException):
  76. """The raw file exception in profiler module."""
  77. def __init__(self, msg):
  78. super(ProfilerRawFileException, self).__init__(
  79. error=ProfilerErrors.RAW_FILE_ERROR,
  80. message=ProfilerErrorMsg.RAW_FILE_ERROR.value.format(msg),
  81. http_code=400
  82. )
  83. class ProfilerColumnNotExistException(MindInsightException):
  84. """The column does not exist exception in profiler module."""
  85. def __init__(self, msg):
  86. super(ProfilerColumnNotExistException, self).__init__(
  87. error=ProfilerErrors.COLUMN_NOT_EXIST_ERROR,
  88. message=ProfilerErrorMsg.COLUMN_NOT_EXIST_ERROR.value.format(msg),
  89. http_code=400
  90. )
  91. class ProfilerAnalyserNotExistException(MindInsightException):
  92. """The analyser in profiler module."""
  93. def __init__(self, msg):
  94. super(ProfilerAnalyserNotExistException, self).__init__(
  95. error=ProfilerErrors.ANALYSER_NOT_EXIST_ERROR,
  96. message=ProfilerErrorMsg.ANALYSER_NOT_EXIST_ERROR.value.format(msg),
  97. http_code=400
  98. )
  99. class ProfilerDeviceIdException(MindInsightException):
  100. """The parameter device_id error in profiler module."""
  101. def __init__(self, msg):
  102. super(ProfilerDeviceIdException, self).__init__(
  103. error=ProfilerErrors.DEVICE_ID_ERROR,
  104. message=ProfilerErrorMsg.DEIVICE_ID_ERROR.value.format(msg),
  105. http_code=400
  106. )
  107. class ProfilerOpTypeException(MindInsightException):
  108. """The parameter op_type error in profiler module."""
  109. def __init__(self, msg):
  110. super(ProfilerOpTypeException, self).__init__(
  111. error=ProfilerErrors.OP_TYPE_ERROR,
  112. message=ProfilerErrorMsg.OP_TYPE_ERROR.value.format(msg),
  113. http_code=400
  114. )
  115. class ProfilerSortConditionException(MindInsightException):
  116. """The parameter sort_condition error in profiler module."""
  117. def __init__(self, msg):
  118. super(ProfilerSortConditionException, self).__init__(
  119. error=ProfilerErrors.SORT_CONDITION_ERROR,
  120. message=ProfilerErrorMsg.SORT_CONDITION_ERROR.value.format(msg),
  121. http_code=400
  122. )
  123. class ProfilerFilterConditionException(MindInsightException):
  124. """The parameter filer_condition error in profiler module."""
  125. def __init__(self, msg):
  126. super(ProfilerFilterConditionException, self).__init__(
  127. error=ProfilerErrors.FILTER_CONDITION_ERROR,
  128. message=ProfilerErrorMsg.FILTER_CONDITION_ERROR.value.format(msg),
  129. http_code=400
  130. )
  131. class ProfilerGroupConditionException(MindInsightException):
  132. """The parameter group_condition error in profiler module."""
  133. def __init__(self, msg):
  134. super(ProfilerGroupConditionException, self).__init__(
  135. error=ProfilerErrors.GROUP_CONDITION_ERROR,
  136. message=ProfilerErrorMsg.GROUP_CONDITION_ERROR.value.format(msg),
  137. http_code=400
  138. )
  139. class ProfilerColumnNotSupportSortException(MindInsightException):
  140. """The column does not support to sort error in profiler module."""
  141. def __init__(self, msg):
  142. super(ProfilerColumnNotSupportSortException, self).__init__(
  143. error=ProfilerErrors.COLUMN_NOT_SUPPORT_SORT_ERROR,
  144. message=ProfilerErrorMsg.COLUMN_NOT_SUPPORT_SORT_ERROR.value.format(msg),
  145. http_code=400
  146. )
  147. class StepNumNotSupportedException(MindInsightException):
  148. """The step number error in profiler module."""
  149. def __init__(self, msg):
  150. super(StepNumNotSupportedException, self).__init__(
  151. error=ProfilerErrors.STEP_NUM_NOT_SUPPORTED_ERROR,
  152. message=ProfilerErrorMsg.STEP_NUM_NOT_SUPPORTED_ERROR.value.format(msg),
  153. http_code=400
  154. )
  155. class JobIdMismatchException(MindInsightException):
  156. """The Job ID mismatch error in profiler module."""
  157. def __init__(self):
  158. super(JobIdMismatchException, self).__init__(
  159. error=ProfilerErrors.JOB_ID_MISMATCH_ERROR,
  160. message=ProfilerErrorMsg.JOB_ID_MISMATCH_ERROR.value,
  161. http_code=400
  162. )
  163. class ProfilerPipelineOpNotExistException(MindInsightException):
  164. """The minddata pipeline operator does not exist error in profiler module."""
  165. def __init__(self, msg):
  166. super(ProfilerPipelineOpNotExistException, self).__init__(
  167. error=ProfilerErrors.PIPELINE_OP_NOT_EXIST_ERROR,
  168. message=ProfilerErrorMsg.PIPELINE_OP_NOT_EXIST_ERROR.value.format(msg),
  169. http_code=400
  170. )