mirror of
https://codeberg.org/PGPainless/cert-d-java.git
synced 2025-12-05 04:41:08 +01:00
Exceptions: Pass in detailed error messages
This commit is contained in:
parent
b9083c4394
commit
3782eb438c
1 changed files with 4 additions and 4 deletions
|
|
@ -48,11 +48,11 @@ public class PGPCertificateDirectory
|
|||
public Certificate getByFingerprint(String fingerprint) throws BadDataException, BadNameException, IOException {
|
||||
if (!openPgpV4FingerprintPattern.matcher(fingerprint).matches() &&
|
||||
!openPgpV6FingerprintPattern.matcher(fingerprint).matches()) {
|
||||
throw new BadNameException();
|
||||
throw new BadNameException("Queried fingerprint '" + fingerprint + "' does neither match OpenPGP v4 nor OpenPGP v6 format.");
|
||||
}
|
||||
Certificate certificate = backend.readByFingerprint(fingerprint);
|
||||
if (certificate == null) {
|
||||
throw new NoSuchElementException();
|
||||
throw new NoSuchElementException("No certificate with fingerprint '" + fingerprint + "' found.");
|
||||
}
|
||||
return certificate;
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ public class PGPCertificateDirectory
|
|||
if (keyMaterial != null) {
|
||||
return keyMaterial.asCertificate();
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
throw new NoSuchElementException("No certificate with special name '" + specialName + "' found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -131,7 +131,7 @@ public class PGPCertificateDirectory
|
|||
try {
|
||||
KeyMaterial keyMaterial = backend.readBySpecialName(SpecialNames.TRUST_ROOT);
|
||||
if (keyMaterial == null) {
|
||||
throw new NoSuchElementException();
|
||||
throw new NoSuchElementException("No trust-root found.");
|
||||
}
|
||||
return keyMaterial;
|
||||
} catch (BadNameException e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue