Coverage for /home/runner/work/coxbuild/coxbuild/src/coxbuild/exceptions.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

13 statements  

1class CoxbuildException(Exception): 

2 """Common base exception for all coxbuild exceptions.""" 

3 

4 def __init__(self, message: str, cause: Exception | None = None) -> None: 

5 """ 

6 Create CoxbuildException. 

7 

8 message: exception mesage 

9 cause: inner exception 

10 """ 

11 super().__init__() 

12 self.message = message 

13 self.cause = cause 

14 

15 def __str__(self) -> str: 

16 return f"{self.message}{f' ({repr(self.cause)})' if self.cause else ''}" 

17 

18 def __repr__(self) -> str: 

19 return str(self) 

20 

21 

22class CoxbuildRuntimeException(CoxbuildException): 

23 """Base exception for runtime errors.""" 

24 pass 

25 

26 

27class CoxbuildSchemaException(CoxbuildException): 

28 """Base exception for schema errors.""" 

29 pass