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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. )
  25. class DebuggerParamValueError(MindInsightException):
  26. """The parameter value error in debugger module."""
  27. def __init__(self, msg):
  28. super(DebuggerParamValueError, self).__init__(
  29. error=DebuggerErrors.PARAM_VALUE_ERROR,
  30. message=DebuggerErrorMsg.PARAM_VALUE_ERROR.value.format(msg)
  31. )
  32. class DebuggerCreateWatchPointError(MindInsightException):
  33. """The error about creating watch point."""
  34. def __init__(self, msg):
  35. super(DebuggerCreateWatchPointError, self).__init__(
  36. error=DebuggerErrors.CREATE_WATCHPOINT_ERROR,
  37. message=DebuggerErrorMsg.CREATE_WATCHPOINT_ERROR.value.format(msg)
  38. )
  39. class DebuggerUpdateWatchPointError(MindInsightException):
  40. """The error about updating watch point."""
  41. def __init__(self, msg):
  42. super(DebuggerUpdateWatchPointError, self).__init__(
  43. error=DebuggerErrors.UPDATE_WATCHPOINT_ERROR,
  44. message=DebuggerErrorMsg.UPDATE_WATCHPOINT_ERROR.value.format(msg)
  45. )
  46. class DebuggerDeleteWatchPointError(MindInsightException):
  47. """The error about deleting watch point."""
  48. def __init__(self, msg):
  49. super(DebuggerDeleteWatchPointError, self).__init__(
  50. error=DebuggerErrors.DELETE_WATCHPOINT_ERROR,
  51. message=DebuggerErrorMsg.DELETE_WATCHPOINT_ERROR.value.format(msg)
  52. )
  53. class DebuggerCompareTensorError(MindInsightException):
  54. """The error about comparing tensors."""
  55. def __init__(self, msg):
  56. super(DebuggerCompareTensorError, self).__init__(
  57. error=DebuggerErrors.COMPARE_TENSOR_ERROR,
  58. message=DebuggerErrorMsg.COMPARE_TENSOR_ERROR.value.format(msg)
  59. )
  60. class DebuggerContinueError(MindInsightException):
  61. """The error about continuing debugging."""
  62. def __init__(self, msg):
  63. super(DebuggerContinueError, self).__init__(
  64. error=DebuggerErrors.CONTINUE_ERROR,
  65. message=DebuggerErrorMsg.CONTINUE_ERROR.value.format(msg)
  66. )
  67. class DebuggerPauseError(MindInsightException):
  68. """The error about pausing debugging."""
  69. def __init__(self, msg):
  70. super(DebuggerPauseError, self).__init__(
  71. error=DebuggerErrors.PAUSE_ERROR,
  72. message=DebuggerErrorMsg.PAUSE_ERROR.value.format(msg)
  73. )
  74. class DebuggerNodeNotInGraphError(MindInsightException):
  75. """The node is not in the graph."""
  76. def __init__(self, node_name, node_type=None):
  77. if node_type is not None:
  78. err_msg = f"Cannot find the node in graph by the given name. node name: {node_name}, type: {node_type}."
  79. else:
  80. err_msg = f"Cannot find the node in graph by the given name. node name: {node_name}."
  81. super(DebuggerNodeNotInGraphError, self).__init__(
  82. error=DebuggerErrors.NODE_NOT_IN_GRAPH_ERROR,
  83. message=err_msg
  84. )
  85. class DebuggerGraphNotExistError(MindInsightException):
  86. """The graph does not exist."""
  87. def __init__(self):
  88. super(DebuggerGraphNotExistError, self).__init__(
  89. error=DebuggerErrors.GRAPH_NOT_EXIST_ERROR,
  90. message=DebuggerErrorMsg.GRAPH_NOT_EXIST_ERROR.value
  91. )