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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 DebuggerCompareTensorError(MindInsightException):
  59. """The error about comparing tensors."""
  60. def __init__(self, msg):
  61. super(DebuggerCompareTensorError, self).__init__(
  62. error=DebuggerErrors.COMPARE_TENSOR_ERROR,
  63. message=DebuggerErrorMsg.COMPARE_TENSOR_ERROR.value.format(msg)
  64. )
  65. class DebuggerContinueError(MindInsightException):
  66. """The error about continuing debugging."""
  67. def __init__(self, msg):
  68. super(DebuggerContinueError, self).__init__(
  69. error=DebuggerErrors.CONTINUE_ERROR,
  70. message=DebuggerErrorMsg.CONTINUE_ERROR.value.format(msg),
  71. http_code=400
  72. )
  73. class DebuggerPauseError(MindInsightException):
  74. """The error about pausing debugging."""
  75. def __init__(self, msg):
  76. super(DebuggerPauseError, self).__init__(
  77. error=DebuggerErrors.PAUSE_ERROR,
  78. message=DebuggerErrorMsg.PAUSE_ERROR.value.format(msg),
  79. http_code=400
  80. )
  81. class DebuggerNodeNotInGraphError(MindInsightException):
  82. """The node is not in the graph."""
  83. def __init__(self, node_name, node_type=None):
  84. if node_type is not None:
  85. err_msg = f"Cannot find the node in graph by the given name. node name: {node_name}, type: {node_type}."
  86. else:
  87. err_msg = f"Cannot find the node in graph by the given name. node name: {node_name}."
  88. super(DebuggerNodeNotInGraphError, self).__init__(
  89. error=DebuggerErrors.NODE_NOT_IN_GRAPH_ERROR,
  90. message=err_msg
  91. )
  92. class DebuggerGraphNotExistError(MindInsightException):
  93. """The graph does not exist."""
  94. def __init__(self):
  95. super(DebuggerGraphNotExistError, self).__init__(
  96. error=DebuggerErrors.GRAPH_NOT_EXIST_ERROR,
  97. message=DebuggerErrorMsg.GRAPH_NOT_EXIST_ERROR.value
  98. )