Coverage for sources/mimeogram/__/exceptions.py: 100%
16 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-17 00:11 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-17 00:11 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
4#============================================================================#
5# #
6# Licensed under the Apache License, Version 2.0 (the "License"); #
7# you may not use this file except in compliance with the License. #
8# You may obtain a copy of the License at #
9# #
10# http://www.apache.org/licenses/LICENSE-2.0 #
11# #
12# Unless required by applicable law or agreed to in writing, software #
13# distributed under the License is distributed on an "AS IS" BASIS, #
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15# See the License for the specific language governing permissions and #
16# limitations under the License. #
17# #
18#============================================================================#
21''' Family of exceptions for package internals.
23 * ``Omniexception``: Base for all internal exceptions
24 * ``Omnierror``: Base for all internals errors
25'''
28from . import imports as __
31class Omniexception( BaseException, metaclass = __.ImmutableClass ):
32 ''' Base for all exceptions raised internally. '''
33 # TODO: Class attribute concealment.
34 # TODO: Instance attribute concealment and immutability.
36 _attribute_visibility_includes_: __.cabc.Collection[ str ] = (
37 frozenset( ( '__cause__', '__context__', ) ) )
40class Omnierror( Omniexception, Exception ):
41 ''' Base for error exceptions raised internally. '''
44class AddressLocateFailure( Omnierror, LookupError ):
45 ''' Failure to locate address. '''
47 def __init__(
48 self, subject: str, address: __.cabc.Sequence[ str ], part: str
49 ):
50 super( ).__init__(
51 f"Could not locate part '{part}' of address '{address}' "
52 f"in {subject}." )
55class AsyncAssertionFailure( Omnierror, AssertionError, TypeError ):
56 ''' Assertion of awaitability of entity failed. '''
58 def __init__( self, entity: __.typx.Any ):
59 super( ).__init__( f"Entity must be awaitable: {entity!r}" )
62class EntryAssertionFailure( Omnierror, AssertionError, KeyError ):
63 ''' Assertion of entry in dictionary failed. '''
65 def __init__( self, subject: str, name: str ):
66 super( ).__init__( f"Could not find entry '{name}' in {subject}." )
69class OperationInvalidity( Omnierror, RuntimeError ):
70 ''' Invalid operation. '''
72 def __init__( self, subject: str, name: str ):
73 super( ).__init__(
74 f"Could not perform operation '{name}' on {subject}." )