Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/coreapi/exceptions.py: 94%

18 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# coding: utf-8 

2from __future__ import unicode_literals 

3 

4 

5class CoreAPIException(Exception): 

6 """ 

7 A base class for all `coreapi` exceptions. 

8 """ 

9 pass 

10 

11 

12class ParseError(CoreAPIException): 

13 """ 

14 Raised when an invalid Core API encoding is encountered. 

15 """ 

16 pass 

17 

18 

19class NoCodecAvailable(CoreAPIException): 

20 """ 

21 Raised when there is no available codec that can handle the given media. 

22 """ 

23 pass 

24 

25 

26class NetworkError(CoreAPIException): 

27 """ 

28 Raised when the transport layer fails to make a request or get a response. 

29 """ 

30 pass 

31 

32 

33class LinkLookupError(CoreAPIException): 

34 """ 

35 Raised when `.action` fails to index a link in the document. 

36 """ 

37 pass 

38 

39 

40class ParameterError(CoreAPIException): 

41 """ 

42 Raised when the parameters passed do not match the link fields. 

43 

44 * A required field was not included. 

45 * An unknown field was included. 

46 * A field was passed an invalid type for the link location/encoding. 

47 """ 

48 pass 

49 

50 

51class ErrorMessage(CoreAPIException): 

52 """ 

53 Raised when the transition returns an error message. 

54 """ 

55 def __init__(self, error): 

56 self.error = error 

57 

58 def __repr__(self): 

59 return '%s(%s)' % (self.__class__.__name__, repr(self.error)) 

60 

61 def __str__(self): 

62 return str(self.error)