Coverage for sources/classcore/exceptions.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-09-25 13:22 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

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#============================================================================# 

19 

20 

21''' Exceptions from package. ''' 

22 

23 

24from . import __ 

25from . import nomina as _nomina 

26from . import standard as _standard 

27 

28 

29exception_mutables_default = ( 

30 '__cause__', '__context__', '__suppress_context__', '__traceback__' ) 

31exception_visibles_default = ( 

32 *exception_mutables_default, _nomina.is_public_identifier ) 

33 

34 

35class Omniexception( 

36 _standard.Object, BaseException, 

37 instances_mutables = exception_mutables_default, 

38 instances_visibles = exception_visibles_default, 

39): 

40 ''' Base exception for package. ''' 

41 

42 

43class Omnierror( Omniexception, Exception ): 

44 ''' Base error for package. ''' 

45 

46 

47class AttributeImmutability( Omnierror, AttributeError ): 

48 

49 def __init__( self, name: str, target: str ): 

50 super( ).__init__( 

51 f"Could not assign or delete attribute {name!r} on {target}." ) 

52 

53 

54class BehaviorExclusionInvalidity( Omnierror, TypeError, ValueError ): 

55 

56 def __init__( self, verifier: __.typx.Any ): 

57 super( ).__init__( 

58 f"Invalid behavior exclusion verifier: {verifier!r}" ) 

59 

60 

61class ErrorProvideFailure( Omnierror, RuntimeError ): 

62 

63 def __init__( self, name: str, reason: str ): 

64 super( ).__init__( 

65 f"Could not provide error class {name!r}. Reason: {reason}" )