The general crypto exception thrown by all methods of the library is com.didisoft.pgp.PGPException. A quick exception handling solution is to catch only PGPException and log it’s stack trace
try { ... } catch (com.didisoft.pgp.PGPException e) { ... } |
However the exception cause can be classified further at runtime, thus identifying what exactly has failed. The distinction of the causes is achieved by sub classes of com.didisoft.pgp.PGPException. They must be called earlier than PGPException.
Below is a list of the exceptions that subclass com.didisoft.pgp.PGPException provided by the library. They are all located in the package com.didisoft.pgp.exceptions
Exception | Short description |
FileIsEncryptedException | Indicates that a file is OpenPGP encrypted |
FileIsPBEEncryptedException | Indicates that a file is encrypted with a password |
IntegrityCheckException | Indicates that an integrity protected archive is corrupted |
KeyIsExpiredException | Shows that a public key we try to use is expired |
KeyIsRevokedException | Shows that a public key we try to use is revoked |
NonPGPDataException | Shows that a file is not an OpenPGP archive |
NoPrivateKeyFoundException | Indicates that the supplied private key source is invalid |
NoPublicKeyFoundException | Indicates that the supplied public key source is invalid |
WrongPasswordException | Indicates that the provided password is wrong |
WrongPrivateKeyException | Shows that an OpenPGP message is archived with a different key than the provided one |
DetachedSignatureException | Thrown when we want to verify a detached signature with a methods that expects a signed file |
Concrete example with the expected PGPException sub classes can be found at the end of each chapter in this tutorial.