Coverage for pyTooling / Exceptions / __init__.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2025-11-21 22:22 +0000

1# ==================================================================================================================== # 

2# # 

3# _____ _ _ _____ _ _ # 

4# _ __ _ |_ _|__ ___ | (_)_ __ __ _ | ____|_ _____ ___ _ __ | |_(_) ___ _ __ ___ # 

5# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` | | _| \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \/ __| # 

6# | |_) | |_| || | (_) | (_) | | | | | | (_| |_| |___ > < (_| __/ |_) | |_| | (_) | | | \__ \ # 

7# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)_____/_/\_\___\___| .__/ \__|_|\___/|_| |_|___/ # 

8# |_| |___/ |___/ |_| # 

9# ==================================================================================================================== # 

10# Authors: # 

11# Patrick Lehmann # 

12# # 

13# License: # 

14# ==================================================================================================================== # 

15# Copyright 2017-2025 Patrick Lehmann - Bötzingen, Germany # 

16# # 

17# Licensed under the Apache License, Version 2.0 (the "License"); # 

18# you may not use this file except in compliance with the License. # 

19# You may obtain a copy of the License at # 

20# # 

21# http://www.apache.org/licenses/LICENSE-2.0 # 

22# # 

23# Unless required by applicable law or agreed to in writing, software # 

24# distributed under the License is distributed on an "AS IS" BASIS, # 

25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

26# See the License for the specific language governing permissions and # 

27# limitations under the License. # 

28# # 

29# SPDX-License-Identifier: Apache-2.0 # 

30# ==================================================================================================================== # 

31# 

32""" 

33A common set of missing exceptions in Python. 

34 

35.. hint:: See :ref:`high-level help <EXECPTION>` for explanations and usage examples. 

36""" 

37try: 

38 from pyTooling.Decorators import export 

39except (ImportError, ModuleNotFoundError): # pragma: no cover 

40 print("[pyTooling.Exceptions] Could not import from 'pyTooling.*'!") 

41 

42 try: 

43 from Decorators import export 

44 except (ImportError, ModuleNotFoundError) as ex: # pragma: no cover 

45 print("[pyTooling.Exceptions] Could not import from 'Decorators' directly!") 

46 raise ex 

47 

48 

49@export 

50class OverloadResolutionError(Exception): 

51 """ 

52 The exception is raised, when no matching overloaded method was found. 

53 

54 .. seealso:: 

55 

56 :func:`@overloadable <pyTooling.MetaClasses.overloadable>` 

57 |rarr| Mark a method as *overloadable*. 

58 """ 

59 

60 

61@export 

62class ExceptionBase(Exception): 

63 """Base exception derived from :exc:`Exception <python:Exception>` for all custom exceptions.""" 

64 

65 def __init__(self, message: str = "") -> None: 

66 """ 

67 ExceptionBase initializer. 

68 

69 :param message: The exception message. 

70 """ 

71 super().__init__() 

72 self.message = message 

73 

74 def __str__(self) -> str: 

75 """Returns the exception's message text.""" 

76 return self.message 

77 

78 # @DocumentMemberAttribute(False) 

79 # @MethodAlias(pyExceptions.with_traceback) 

80 # def with_traceback(self): pass 

81 

82 

83@export 

84class EnvironmentException(ExceptionBase): 

85 """The exception is raised when an expected environment variable is missing.""" 

86 

87 

88@export 

89class PlatformNotSupportedException(ExceptionBase): 

90 """The exception is raise if the platform is not supported.""" 

91 

92 

93@export 

94class NotConfiguredException(ExceptionBase): 

95 """The exception is raise if the requested setting is not configured.""" 

96 

97 

98@export 

99class ToolingException(Exception): 

100 """The exception is raised by pyTooling internal features."""