Coverage for pyTooling / Exceptions / __init__.py: 100%
19 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-26 01:44 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-26 01:44 +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.
35.. hint::
37 See :ref:`high-level help <EXECPTION>` for explanations and usage examples.
38"""
39try:
40 from pyTooling.Decorators import export
41except (ImportError, ModuleNotFoundError): # pragma: no cover
42 print("[pyTooling.Exceptions] Could not import from 'pyTooling.*'!")
44 try:
45 from Decorators import export
46 except (ImportError, ModuleNotFoundError) as ex: # pragma: no cover
47 print("[pyTooling.Exceptions] Could not import from 'Decorators' directly!")
48 raise ex
51@export
52class OverloadResolutionError(Exception):
53 """
54 The exception is raised, when no matching overloaded method was found.
56 .. seealso::
58 :func:`@overloadable <pyTooling.MetaClasses.overloadable>`
59 |rarr| Mark a method as *overloadable*.
60 """
63@export
64class ExceptionBase(Exception):
65 """Base exception derived from :exc:`Exception <python:Exception>` for all custom exceptions."""
67 def __init__(self, message: str = "") -> None:
68 """
69 ExceptionBase initializer.
71 :param message: The exception message.
72 """
73 super().__init__()
74 self.message = message
76 def __str__(self) -> str:
77 """Returns the exception's message text."""
78 return self.message
80 # @DocumentMemberAttribute(False)
81 # @MethodAlias(pyExceptions.with_traceback)
82 # def with_traceback(self): pass
85@export
86class EnvironmentException(ExceptionBase):
87 """The exception is raised when an expected environment variable is missing."""
90@export
91class PlatformNotSupportedException(ExceptionBase):
92 """The exception is raise if the platform is not supported."""
95@export
96class NotConfiguredException(ExceptionBase):
97 """The exception is raise if the requested setting is not configured."""
100@export
101class ToolingException(Exception):
102 """The exception is raised by pyTooling internal features."""