Skip to content

Clearer distinction of some well defined errors #1200

@chilledgeek

Description

@chilledgeek

Explanation

  • Would be good to have clearer distinction of some well defined errors (that we want to detect) from the generic PdfReadError:
    • WrongPasswordError
    • FileNotDecryptedError
    • EmptyFileError
  • This makes it cleaner for error catching and handling (instead of inspecting the args within the error message)

Code Example

from PyPDF2 import PdfReader, PdfWriter
from PyPDF2.errors import FileNotDecryptedError

filepath = "encrypted.pdf"
try:
    PdfReader(filepath)
except FileNotDecryptedError:
    # do something...specifically for this error!
    # and not have to dig through the args of the error to pick out this specific error...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions