Coverage for agentlib/core/errors.py: 50%

8 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2025-04-07 16:27 +0000

1"""This module implements custom errors to ensure 

2a better understand of errors in the agentlib""" 

3 

4 

5class InitializationError(Exception): 

6 """ 

7 Exception raised for errors due to wrong initialization of modules. 

8 """ 

9 

10 

11class ConfigurationError(Exception): 

12 """ 

13 Exception raised for errors due to wrong configuration of modules. 

14 """ 

15 

16 

17class OptionalDependencyError(Exception): 

18 """ 

19 Exception to indicate that an optional dependency is missing 

20 which can always be fixed by installing the missing 

21 dependency. 

22 """ 

23 

24 def __init__( 

25 self, 

26 used_object: str, 

27 dependency_install: str, 

28 dependency_name: str = None, 

29 ): 

30 message = ( 

31 f"{used_object} is an optional dependency which you did not " 

32 f"install yet. Install the missing dependency " 

33 f"using `pip install {dependency_install}`" 

34 ) 

35 if dependency_name is not None: 

36 message += ( 

37 ", or by re-installing the agentlib using " 

38 "`pip install agentlib[full]` or just the " 

39 f"key (e.g. for {dependency_name}: " 

40 f"`pip install agentlib[{dependency_name}]`" 

41 ) 

42 super().__init__(message)