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.

error_code.py 3.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright 2020-2021 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. """Debugger error code and messages."""
  16. from enum import Enum, unique
  17. from mindinsight.utils.constant import DebuggerErrors as DebuggerErrorCodes
  18. _PARAM_ERROR_MASK = 0b00001 << 7
  19. _DEBUGGER_GRAPH_ERROR = 0b00010 << 7
  20. _DEBUGGER_RUNNING_ERROR = 0b00011 << 7
  21. _DEBUGGER_SERVER_ERROR = 0b00100 << 7
  22. _DEBUGGER_SESSION_ERROR = 0b00101 << 7
  23. @unique
  24. class DebuggerErrors(DebuggerErrorCodes):
  25. """Debugger error codes."""
  26. PARAM_TYPE_ERROR = 0 | _PARAM_ERROR_MASK
  27. PARAM_VALUE_ERROR = 1 | _PARAM_ERROR_MASK
  28. STEP_NUM_ERROR = 2 | _PARAM_ERROR_MASK
  29. DEBUGGER_CONDITION_UNAVAILABLE_ERROR = 3 | _PARAM_ERROR_MASK
  30. NODE_NOT_IN_GRAPH_ERROR = 0 | _DEBUGGER_GRAPH_ERROR
  31. GRAPH_NOT_EXIST_ERROR = 1 | _DEBUGGER_GRAPH_ERROR
  32. CREATE_WATCHPOINT_ERROR = 0 | _DEBUGGER_RUNNING_ERROR
  33. UPDATE_WATCHPOINT_ERROR = 1 | _DEBUGGER_RUNNING_ERROR
  34. DELETE_WATCHPOINT_ERROR = 2 | _DEBUGGER_RUNNING_ERROR
  35. CONTINUE_ERROR = 3 | _DEBUGGER_RUNNING_ERROR
  36. PAUSE_ERROR = 4 | _DEBUGGER_RUNNING_ERROR
  37. COMPARE_TENSOR_ERROR = 5 | _DEBUGGER_RUNNING_ERROR
  38. RECHECK_ERROR = 6 | _DEBUGGER_RUNNING_ERROR
  39. TENSOR_GRAPH_ERROR = 7 | _DEBUGGER_RUNNING_ERROR
  40. TENSOR_HIT_ERROR = 8 | _DEBUGGER_RUNNING_ERROR
  41. SET_RECOMMEND_WATCHPOINT_ERROR = 9 | _DEBUGGER_RUNNING_ERROR
  42. DEBUGGER_SERVER_RUNNING_ERROR = 0 | _DEBUGGER_SERVER_ERROR
  43. DEVICE_ID_UNREGISTERED = 1 | _DEBUGGER_SERVER_ERROR
  44. MODULE_NOT_FOUND_ERROR = 2 | _DEBUGGER_SERVER_ERROR
  45. DEBUGGER_SESSION_OVER_BOUND_ERROR = 0 | _DEBUGGER_SESSION_ERROR
  46. DEBUGGER_SESSION_NOT_FOUND_ERROR = 1 | _DEBUGGER_SESSION_ERROR
  47. @unique
  48. class DebuggerErrorMsg(Enum):
  49. """Debugger error messages."""
  50. PARAM_TYPE_ERROR = "TypeError. {}"
  51. PARAM_VALUE_ERROR = "ValueError. {}"
  52. DEBUGGER_CONDITION_UNAVAILABLE_ERROR = "Condition is unavailable. {}"
  53. GRAPH_NOT_EXIST_ERROR = "The graph does not exist."
  54. CREATE_WATCHPOINT_ERROR = "Create watchpoint failed. {}"
  55. UPDATE_WATCHPOINT_ERROR = "Update watchpoint failed. {}"
  56. DELETE_WATCHPOINT_ERROR = "Delete watchpoint failed. {}"
  57. CONTINUE_ERROR = "Continue debugging failed. {}"
  58. PAUSE_ERROR = "Pause debugging failed. {}"
  59. RECHECK_ERROR = "Recheck failed. {}"
  60. TENSOR_GRAPH_ERROR = "Get tensor graphs failed."
  61. TENSOR_HIT_ERROR = "Get tensor hits failed."
  62. SET_RECOMMEND_WATCHPOINT_ERROR = "Set Recommend Watchpoints failed."
  63. DEBUGGER_SERVER_RUNNING_ERROR = "Debugger server running error. {}"
  64. DEVICE_ID_UNREGISTERED = "Device id unregistered. Device id: {}"
  65. MODULE_NOT_FOUND_ERROR = "{} module not found."
  66. DEBUGGER_SESSION_OVER_BOUND_ERROR = "The amount of sessions is over limitation."
  67. DEBUGGER_SESSION_NOT_FOUND_ERROR = "Session {} not found."