Exception: HexaPDF::MalformedPDFError

Inherits:
Error
  • Object
show all
Defined in:
lib/hexapdf/error.rb

Overview

Raised when the PDF is invalid and can’t be read correctly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, pos: nil) ⇒ MalformedPDFError

Creates a new malformed PDF error object for the given exception message.

The byte position where the error occured can either be given via the pos argument or later via the #pos accessor but must be set before the exception message is retrieved.



52
53
54
55
# File 'lib/hexapdf/error.rb', line 52

def initialize(message, pos: nil)
  super(message)
  @pos = pos
end

Instance Attribute Details

#posObject

The byte position in the PDF file where the error occured.



46
47
48
# File 'lib/hexapdf/error.rb', line 46

def pos
  @pos
end

Instance Method Details

#messageObject

:nodoc:



57
58
59
# File 'lib/hexapdf/error.rb', line 57

def message # :nodoc:
  "PDF malformed around position #{pos}: #{super}"
end