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

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