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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright 2019 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 ScriptConverterErrors
  18. from mindinsight.utils.exceptions import MindInsightException
  19. @unique
  20. class ConverterErrors(ScriptConverterErrors):
  21. """Converter error codes."""
  22. SCRIPT_NOT_SUPPORT = 1
  23. NODE_TYPE_NOT_SUPPORT = 2
  24. CODE_SYNTAX_ERROR = 3
  25. class ScriptNotSupport(MindInsightException):
  26. """The script can not support to process."""
  27. def __init__(self, msg):
  28. super(ScriptNotSupport, self).__init__(ConverterErrors.SCRIPT_NOT_SUPPORT,
  29. msg,
  30. http_code=400)
  31. class NodeTypeNotSupport(MindInsightException):
  32. """The astNode can not support to process."""
  33. def __init__(self, msg):
  34. super(NodeTypeNotSupport, self).__init__(ConverterErrors.NODE_TYPE_NOT_SUPPORT,
  35. msg,
  36. http_code=400)
  37. class CodeSyntaxError(MindInsightException):
  38. """The CodeSyntaxError class definition."""
  39. def __init__(self, msg):
  40. super(CodeSyntaxError, self).__init__(ConverterErrors.CODE_SYNTAX_ERROR,
  41. msg,
  42. http_code=400)