lib/hexapdf/error.rb in hexapdf-0.6.0 vs lib/hexapdf/error.rb in hexapdf-0.7.0

- old
+ new

@@ -1,12 +1,12 @@ -# -*- encoding: utf-8 -*- +# -*- encoding: utf-8; frozen_string_literal: true -*- # #-- # This file is part of HexaPDF. # # HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby -# Copyright (C) 2014-2017 Thomas Leitner +# Copyright (C) 2014-2018 Thomas Leitner # # HexaPDF is free software: you can redistribute it and/or modify it # under the terms of the GNU Affero General Public License version 3 as # published by the Free Software Foundation with the addition of the # following permission added to Section 15 as permitted in Section 7(a): @@ -40,21 +40,19 @@ class MalformedPDFError < Error # The byte position in the PDF file where the error occured. attr_reader :pos - # Creates a new malformed PDF error object for the given exception or exception message. + # Creates a new malformed PDF error object for the given exception message. # - # The byte position where the error occured can be given via the optional +pos+ argument. - def initialize(msg_or_error, pos: nil) - super(msg_or_error) - set_backtrace(msg_or_error.backtrace) if msg_or_error.kind_of?(Exception) + # The byte position where the error occured has to be given via the +pos+ argument. + def initialize(message, pos:) + super(message) @pos = pos end def message # :nodoc: - pos_msg = @pos.nil? ? '' : " around position #{pos}" - "PDF malformed#{pos_msg}: #{super}" + "PDF malformed around position #{pos}: #{super}" end end # Raised when a filter encounters a problem during decoding or encoding.