lib/hexapdf/error.rb in hexapdf-0.31.0 vs lib/hexapdf/error.rb in hexapdf-0.32.0

- old
+ new

@@ -2,11 +2,11 @@ # #-- # This file is part of HexaPDF. # # HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby -# Copyright (C) 2014-2022 Thomas Leitner +# Copyright (C) 2014-2023 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): @@ -65,10 +65,20 @@ # Raised when a PDF object contains invalid data. class InvalidPDFObjectError < Error; end # Raised when there are problems while encrypting or decrypting a document. - class EncryptionError < Error; end + class EncryptionError < Error + + # The PDF object that caused the problem. May not be set in case of general problems unrelated + # to a specific PDF object. + attr_accessor :pdf_object + + def message # :nodoc: + pdf_object ? "Object (#{pdf_object.oid},#{pdf_object.gen}): #{super}" : super + end + + end # Raised when the encryption method is not supported. class UnsupportedEncryptionError < EncryptionError; end end