Coverage for sources/accretive/exceptions.py: 100%
16 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-26 03:08 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-26 03:08 +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 API.
23 Provides a hierarchy of exceptions that are raised when accretive behavior
24 is violated. The hierarchy is designed to allow both specific and general
25 exception handling.
26'''
29from . import __
30from . import classes as _classes
33class Omniexception(
34 _classes.Object, BaseException,
35 instances_mutables = __.ccexc.exception_mutables_default,
36 instances_visibles = __.ccexc.exception_visibles_default,
37):
38 ''' Base exceptions for package. '''
41class Omnierror( Omniexception, Exception ):
42 ''' Base for error exceptions raised by package API. '''
45class AttributeImmutability( Omnierror, AttributeError, TypeError ):
47 def __init__( self, name: str, target: str ):
48 super( ).__init__(
49 f"Could not assign or delete attribute {name!r} on {target}." )
52class EntryImmutability( Omnierror, TypeError ):
54 def __init__( self, indicator: __.cabc.Hashable ) -> None:
55 super( ).__init__(
56 f"Could not alter or remove existing entry for {indicator!r}." )
59class EntryInvalidity( Omnierror, ValueError ):
61 def __init__(
62 self, indicator: __.cabc.Hashable, value: __.typx.Any
63 ) -> None:
64 super( ).__init__(
65 f"Could not add invalid entry with key, {indicator!r}, "
66 f"and value, {value!r}, to dictionary." )
69class ErrorProvideFailure( Omnierror, RuntimeError ):
71 def __init__( self, name: str, reason: str ):
72 super( ).__init__(
73 f"Could not provide error class {name!r}. Reason: {reason}" )