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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. """Profiler error code and messages."""
  16. from enum import unique, Enum
  17. from mindinsight.utils.constant import ProfilerMgrErrors
  18. _GENERAL_MASK = 0b00001 << 7
  19. _PARSER_MASK = 0b00010 << 7
  20. _ANALYSER_MASK = 0b00011 << 7
  21. @unique
  22. class ProfilerErrors(ProfilerMgrErrors):
  23. """Profiler error codes."""
  24. # general error code
  25. PARAM_VALUE_ERROR = 0 | _GENERAL_MASK
  26. PATH_ERROR = 1 | _GENERAL_MASK
  27. PARAM_TYPE_ERROR = 2 | _GENERAL_MASK
  28. DIR_NOT_FOUND_ERROR = 3 | _GENERAL_MASK
  29. FILE_NOT_FOUND_ERROR = 4 | _GENERAL_MASK
  30. IO_ERROR = 5 | _GENERAL_MASK
  31. # parser error code
  32. DEVICE_ID_MISMATCH_ERROR = 0 | _PARSER_MASK
  33. RAW_FILE_ERROR = 1 | _PARSER_MASK
  34. # analyser error code
  35. COLUMN_NOT_EXIST_ERROR = 0 | _ANALYSER_MASK
  36. ANALYSER_NOT_EXIST_ERROR = 1 | _ANALYSER_MASK
  37. DEVICE_ID_ERROR = 2 | _ANALYSER_MASK
  38. OP_TYPE_ERROR = 3 | _ANALYSER_MASK
  39. GROUP_CONDITION_ERROR = 4 | _ANALYSER_MASK
  40. SORT_CONDITION_ERROR = 5 | _ANALYSER_MASK
  41. FILTER_CONDITION_ERROR = 6 | _ANALYSER_MASK
  42. @unique
  43. class ProfilerErrorMsg(Enum):
  44. """Profiler error messages."""
  45. # general error msg
  46. PARAM_VALUE_ERROR = 'Param value error. {}'
  47. PATH_ERROR = 'Path error. {}'
  48. PARAM_TYPE_ERROR = 'Param type error. {}'
  49. DIR_NOT_FOUND_ERROR = 'The dir <{}> not found.'
  50. FILE_NOT_FOUND_ERROR = 'The file <{}> not found.'
  51. IO_ERROR = 'Read or write file fail.'
  52. # parser error msg
  53. DEVICE_ID_MISMATCH_ERROR = 'The device ID mismatch.'
  54. RAW_FILE_ERROR = 'Raw file error. {}'
  55. # analyser error msg
  56. COLUMN_NOT_EXIST_ERROR = 'The column {} does not exist.'
  57. ANALYSER_NOT_EXIST_ERROR = 'The analyser {} does not exist.'
  58. DEIVICE_ID_ERROR = 'The device_id in search_condition error, {}'
  59. FILTER_CONDITION_ERROR = 'The filter_condition in search_condition error, {}'
  60. OP_TYPE_ERROR = 'The op_type in search_condition error, {}'
  61. GROUP_CONDITION_ERROR = 'The group_condition in search_condition error, {}'
  62. SORT_CONDITION_ERROR = 'The sort_condition in search_condition error, {}'