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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. @unique
  38. class ProfilerErrorMsg(Enum):
  39. """Profiler error messages."""
  40. # general error msg
  41. PARAM_VALUE_ERROR = 'Param value error. {}'
  42. PATH_ERROR = 'Path error. {}'
  43. PARAM_TYPE_ERROR = 'Param type error. {}'
  44. DIR_NOT_FOUND_ERROR = 'The dir <{}> not found.'
  45. FILE_NOT_FOUND_ERROR = 'The file <{}> not found.'
  46. IO_ERROR = 'Read or write file fail.'
  47. # parser error msg
  48. DEVICE_ID_MISMATCH_ERROR = 'The device ID mismatch.'
  49. RAW_FILE_ERROR = 'Raw file error. {}'
  50. # analyser error msg
  51. COLUMN_NOT_EXIST_ERROR = 'The column {} does not exist.'
  52. ANALYSER_NOT_EXIST_ERROR = 'The analyser {} does not exist.'