Coverage for pdfrw/pdfrw/errors.py: 88%

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

16 statements  

1# A part of pdfrw (https://github.com/pmaupin/pdfrw) 

2# Copyright (C) 2006-2015 Patrick Maupin, Austin, Texas 

3# MIT license -- See LICENSE.txt for details 

4 

5''' 

6PDF Exceptions and error handling 

7''' 

8 

9import logging 

10 

11 

12fmt = logging.Formatter('[%(levelname)s] %(filename)s:%(lineno)d %(message)s') 

13 

14handler = logging.StreamHandler() 

15handler.setFormatter(fmt) 

16 

17log = logging.getLogger('pdfrw') 

18log.setLevel(logging.WARNING) 

19log.addHandler(handler) 

20 

21 

22class PdfError(Exception): 

23 "Abstract base class of exceptions thrown by this module" 

24 

25 def __init__(self, msg): 

26 self.msg = msg 

27 

28 def __str__(self): 

29 return self.msg 

30 

31 

32class PdfParseError(PdfError): 

33 "Error thrown by parser/tokenizer" 

34 

35 

36class PdfOutputError(PdfError): 

37 "Error thrown by PDF writer" 

38 

39 

40class PdfNotImplementedError(PdfError): 

41 "Error thrown on missing features"