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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. """Define custom exception."""
  16. from enum import unique
  17. from mindinsight.utils.constant import WizardErrors
  18. from mindinsight.utils.exceptions import MindInsightException
  19. @unique
  20. class WizardErrorCodes(WizardErrors):
  21. """Wizard error codes."""
  22. CODE_SYNTAX_ERROR = 1
  23. OS_PERMISSION_ERROR = 2
  24. COMMAND_ERROR = 3
  25. TEMPLATE_FILE_ERROR = 4
  26. class CodeSyntaxError(MindInsightException):
  27. """The CodeSyntaxError class definition."""
  28. def __init__(self, msg):
  29. super(CodeSyntaxError, self).__init__(WizardErrorCodes.CODE_SYNTAX_ERROR, msg)
  30. class OSPermissionError(MindInsightException):
  31. def __init__(self, msg):
  32. super(OSPermissionError, self).__init__(WizardErrorCodes.OS_PERMISSION_ERROR, msg)
  33. class CommandError(MindInsightException):
  34. def __init__(self, msg):
  35. super(CommandError, self).__init__(WizardErrorCodes.COMMAND_ERROR, msg)
  36. class TemplateFileError(MindInsightException):
  37. def __init__(self, msg):
  38. super(TemplateFileError, self).__init__(WizardErrorCodes.TEMPLATE_FILE_ERROR, msg)