Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pypdf/errors.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

14 statements  

1""" 

2All errors/exceptions pypdf raises and all of the warnings it uses. 

3 

4Please note that broken PDF files might cause other Exceptions. 

5""" 

6 

7 

8class DeprecationError(Exception): 

9 """Raised when a deprecated feature is used.""" 

10 

11 

12class DependencyError(Exception): 

13 """ 

14 Raised when a required dependency (a library or module that pypdf depends on) 

15 is not available or cannot be imported. 

16 """ 

17 

18 

19class PyPdfError(Exception): 

20 """Base class for all exceptions raised by pypdf.""" 

21 

22 

23class PdfReadError(PyPdfError): 

24 """Raised when there is an issue reading a PDF file.""" 

25 

26 

27class PageSizeNotDefinedError(PyPdfError): 

28 """Raised when the page size of a PDF document is not defined.""" 

29 

30 

31class PdfReadWarning(UserWarning): 

32 """Issued when there is a potential issue reading a PDF file, but it can still be read.""" 

33 

34 

35class PdfStreamError(PdfReadError): 

36 """Raised when there is an issue reading the stream of data in a PDF file.""" 

37 

38 

39class ParseError(PyPdfError): 

40 """ 

41 Raised when there is an issue parsing (analyzing and understanding the 

42 structure and meaning of) a PDF file. 

43 """ 

44 

45 

46class FileNotDecryptedError(PdfReadError): 

47 """ 

48 Raised when a PDF file that has been encrypted 

49 (meaning it requires a password to be accessed) has not been successfully 

50 decrypted. 

51 """ 

52 

53 

54class WrongPasswordError(FileNotDecryptedError): 

55 """Raised when the wrong password is used to try to decrypt an encrypted PDF file.""" 

56 

57 

58class EmptyFileError(PdfReadError): 

59 """Raised when a PDF file is empty or has no content.""" 

60 

61 

62class EmptyImageDataError(PyPdfError): 

63 """Raised when trying to process an image that has no data.""" 

64 

65 

66STREAM_TRUNCATED_PREMATURELY = "Stream has ended unexpectedly"