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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. NODE_INPUT_TYPE_NOT_SUPPORT = 4
  26. class ScriptNotSupport(MindInsightException):
  27. """The script can not support to process."""
  28. def __init__(self, msg):
  29. super(ScriptNotSupport, self).__init__(ConverterErrors.SCRIPT_NOT_SUPPORT,
  30. msg,
  31. http_code=400)
  32. class NodeTypeNotSupport(MindInsightException):
  33. """The astNode can not support to process."""
  34. def __init__(self, msg):
  35. super(NodeTypeNotSupport, self).__init__(ConverterErrors.NODE_TYPE_NOT_SUPPORT,
  36. msg,
  37. http_code=400)
  38. class CodeSyntaxError(MindInsightException):
  39. """The CodeSyntaxError class definition."""
  40. def __init__(self, msg):
  41. super(CodeSyntaxError, self).__init__(ConverterErrors.CODE_SYNTAX_ERROR,
  42. msg,
  43. http_code=400)
  44. class NodeInputTypeNotSupport(MindInsightException):
  45. """The node input type NOT support error."""
  46. def __init__(self, msg):
  47. super(NodeInputTypeNotSupport, self).__init__(ConverterErrors.NODE_INPUT_TYPE_NOT_SUPPORT,
  48. msg,
  49. http_code=400)