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.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 debugger module."""
  16. from mindinsight.utils.exceptions import MindInsightException
  17. from mindinsight.debugger.common.exceptions.error_code import DebuggerErrors, DebuggerErrorMsg
  18. class DebuggerParamTypeError(MindInsightException):
  19. """The parameter type error in debugger module."""
  20. def __init__(self, msg):
  21. super(DebuggerParamTypeError, self).__init__(
  22. error=DebuggerErrors.PARAM_TYPE_ERROR,
  23. message=DebuggerErrorMsg.PARAM_TYPE_ERROR.value.format(msg),
  24. http_code=400
  25. )
  26. class DebuggerParamValueError(MindInsightException):
  27. """The parameter value error in debugger module."""
  28. def __init__(self, msg):
  29. super(DebuggerParamValueError, self).__init__(
  30. error=DebuggerErrors.PARAM_VALUE_ERROR,
  31. message=DebuggerErrorMsg.PARAM_VALUE_ERROR.value.format(msg),
  32. http_code=400
  33. )
  34. class DebuggerCreateWatchPointError(MindInsightException):
  35. """The error about creating watch point."""
  36. def __init__(self, msg):
  37. super(DebuggerCreateWatchPointError, self).__init__(
  38. error=DebuggerErrors.CREATE_WATCHPOINT_ERROR,
  39. message=DebuggerErrorMsg.CREATE_WATCHPOINT_ERROR.value.format(msg),
  40. http_code=400
  41. )
  42. class DebuggerUpdateWatchPointError(MindInsightException):
  43. """The error about updating watch point."""
  44. def __init__(self, msg):
  45. super(DebuggerUpdateWatchPointError, self).__init__(
  46. error=DebuggerErrors.UPDATE_WATCHPOINT_ERROR,
  47. message=DebuggerErrorMsg.UPDATE_WATCHPOINT_ERROR.value.format(msg),
  48. http_code=400
  49. )
  50. class DebuggerDeleteWatchPointError(MindInsightException):
  51. """The error about deleting watch point."""
  52. def __init__(self, msg):
  53. super(DebuggerDeleteWatchPointError, self).__init__(
  54. error=DebuggerErrors.DELETE_WATCHPOINT_ERROR,
  55. message=DebuggerErrorMsg.DELETE_WATCHPOINT_ERROR.value.format(msg),
  56. http_code=400
  57. )
  58. class DebuggerRecheckError(MindInsightException):
  59. """The error about deleting watch point."""
  60. def __init__(self, msg):
  61. super(DebuggerRecheckError, self).__init__(
  62. error=DebuggerErrors.RECHECK_ERROR,
  63. message=DebuggerErrorMsg.RECHECK_ERROR.value.format(msg),
  64. http_code=400
  65. )
  66. class DebuggerCompareTensorError(MindInsightException):
  67. """The error about comparing tensors."""
  68. def __init__(self, msg):
  69. super(DebuggerCompareTensorError, self).__init__(
  70. error=DebuggerErrors.COMPARE_TENSOR_ERROR,
  71. message=msg,
  72. http_code=400
  73. )
  74. class DebuggerContinueError(MindInsightException):
  75. """The error about continuing debugging."""
  76. def __init__(self, msg):
  77. super(DebuggerContinueError, self).__init__(
  78. error=DebuggerErrors.CONTINUE_ERROR,
  79. message=DebuggerErrorMsg.CONTINUE_ERROR.value.format(msg),
  80. http_code=400
  81. )
  82. class DebuggerPauseError(MindInsightException):
  83. """The error about pausing debugging."""
  84. def __init__(self, msg):
  85. super(DebuggerPauseError, self).__init__(
  86. error=DebuggerErrors.PAUSE_ERROR,
  87. message=DebuggerErrorMsg.PAUSE_ERROR.value.format(msg),
  88. http_code=400
  89. )
  90. class DebuggerNodeNotInGraphError(MindInsightException):
  91. """The node is not in the graph."""
  92. def __init__(self, node_name, node_type=None):
  93. if node_type is not None:
  94. err_msg = f"Cannot find the node in graph by the given name. node name: {node_name}, type: {node_type}."
  95. else:
  96. err_msg = f"Cannot find the node in graph by the given name. node name: {node_name}."
  97. super(DebuggerNodeNotInGraphError, self).__init__(
  98. error=DebuggerErrors.NODE_NOT_IN_GRAPH_ERROR,
  99. message=err_msg,
  100. http_code=400
  101. )
  102. class DebuggerGraphNotExistError(MindInsightException):
  103. """The graph does not exist."""
  104. def __init__(self):
  105. super(DebuggerGraphNotExistError, self).__init__(
  106. error=DebuggerErrors.GRAPH_NOT_EXIST_ERROR,
  107. message=DebuggerErrorMsg.GRAPH_NOT_EXIST_ERROR.value,
  108. http_code=400
  109. )
  110. class DebuggerStepNumError(MindInsightException):
  111. """The graph does not exist."""
  112. def __init__(self):
  113. super(DebuggerStepNumError, self).__init__(
  114. error=DebuggerErrors.STEP_NUM_ERROR,
  115. message="The type of step number should be int32.",
  116. http_code=400
  117. )
  118. class DebuggerTensorGraphError(MindInsightException):
  119. """The error about comparing tensors."""
  120. def __init__(self):
  121. super(DebuggerTensorGraphError, self).__init__(
  122. error=DebuggerErrors.TENSOR_GRAPH_ERROR,
  123. message=DebuggerErrorMsg.TENSOR_GRAPH_ERROR.value,
  124. http_code=400
  125. )
  126. class DebuggerTensorHitError(MindInsightException):
  127. """The error about comparing tensors."""
  128. def __init__(self):
  129. super(DebuggerTensorHitError, self).__init__(
  130. error=DebuggerErrors.TENSOR_HIT_ERROR,
  131. message=DebuggerErrorMsg.TENSOR_HIT_ERROR.value,
  132. http_code=400
  133. )