Coverage for /Users/buh/.pyenv/versions/3.12.9/envs/es-testbed/lib/python3.12/site-packages/es_testbed/exceptions.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-16 12:20 -0600

1"""es-testbed Exceptions""" 

2 

3from typing import Any, Tuple 

4 

5 

6class TestbedException(Exception): # parent exception 

7 """ 

8 Base class for all exceptions raised by the tool which are not Elasticsearch 

9 or es_client exceptions. 

10 

11 For the 'errors' attribute, errors are ordered from 

12 most recently raised (index=0) to least recently raised (index=N) 

13 """ 

14 

15 __test__ = False 

16 

17 def __init__(self, message: Any, errors: Tuple[Exception, ...] = ()): 

18 super().__init__(message) 

19 self.message = message 

20 self.errors = tuple(errors) 

21 

22 def __repr__(self) -> str: 

23 parts = [repr(self.message)] 

24 if self.errors: 

25 parts.append(f"errors={self.errors!r}") 

26 return f'{self.__class__.__name__}({", ".join(parts)})' 

27 

28 def __str__(self) -> str: 

29 return str(self.message) 

30 

31 

32class MissingArgument(TestbedException): 

33 """ 

34 An expected argument was missing 

35 """ 

36 

37 

38class NameChanged(TestbedException): 

39 """ 

40 An index name changed, likely due to an ILM promotion to cold or frozen 

41 """ 

42 

43 

44class StepChanged(TestbedException): 

45 """ 

46 The current step changed since the initial API call was formed 

47 """ 

48 

49 

50class ResultNotExpected(TestbedException): 

51 """ 

52 The result we got is not what we expected 

53 """ 

54 

55 

56class TestbedFailure(TestbedException): 

57 """ 

58 Whatever we were trying to do failed. 

59 """ 

60 

61 __test__ = False 

62 

63 

64class TestbedMisconfig(TestbedException): 

65 """ 

66 There was a misconfiguration encountered. 

67 """ 

68 

69 __test__ = False 

70 

71 

72class TestPlanMisconfig(TestbedMisconfig): 

73 """ 

74 There was a misconfiguration in a TestPlan. 

75 """ 

76 

77 __test__ = False 

78 

79 

80class TimeoutException(TestbedException): 

81 """ 

82 An process took too long to complete 

83 """