Exception: HexaPDF::MalformedPDFError
- Defined in:
- lib/hexapdf/error.rb
Overview
Raised when the PDF is invalid and can’t be read correctly.
Instance Attribute Summary collapse
-
#pos ⇒ Object
readonly
The byte position in the PDF file where the error occured.
Instance Method Summary collapse
-
#initialize(msg_or_error, pos: nil) ⇒ MalformedPDFError
constructor
Creates a new malformed PDF error object for the given exception or exception message.
-
#message ⇒ Object
:nodoc:.
Constructor Details
#initialize(msg_or_error, pos: nil) ⇒ MalformedPDFError
Creates a new malformed PDF error object for the given exception or exception message.
The byte position where the error occured can be given via the optional pos
argument.
48 49 50 51 52 |
# File 'lib/hexapdf/error.rb', line 48 def initialize(msg_or_error, pos: nil) super(msg_or_error) set_backtrace(msg_or_error.backtrace) if msg_or_error.kind_of?(Exception) @pos = pos end |
Instance Attribute Details
#pos ⇒ Object (readonly)
The byte position in the PDF file where the error occured.
43 44 45 |
# File 'lib/hexapdf/error.rb', line 43 def pos @pos end |
Instance Method Details
#message ⇒ Object
:nodoc:
54 55 56 57 |
# File 'lib/hexapdf/error.rb', line 54 def # :nodoc: pos_msg = @pos.nil? ? '' : " around position #{pos}" "PDF malformed#{pos_msg}: #{super}" end |