diff options
author | Thomas <> | 2023-04-11 12:36:16 +0200 |
---|---|---|
committer | Thomas <> | 2023-04-11 12:36:16 +0200 |
commit | eb9753090223c512c030a6daa13dcd4e0c5886d8 (patch) | |
tree | 1dc3de91af441f3afaa8f109d9aad44895cc2b0a | |
parent | b3f3e25dfd9e750ff7fb9ecd14057677a66d926b (diff) | |
download | pdf-as-4-eb9753090223c512c030a6daa13dcd4e0c5886d8.tar.gz pdf-as-4-eb9753090223c512c030a6daa13dcd4e0c5886d8.tar.bz2 pdf-as-4-eb9753090223c512c030a6daa13dcd4e0c5886d8.zip |
chore(pdf-as-web): optimize error-handling
Before, PDFASExceptions are dispalyed as generic errors
3 files changed, 7 insertions, 0 deletions
diff --git a/pdf-as-common/src/main/resources/resources/messages/error.properties b/pdf-as-common/src/main/resources/resources/messages/error.properties index 4f67fff6..6ed97e59 100644 --- a/pdf-as-common/src/main/resources/resources/messages/error.properties +++ b/pdf-as-common/src/main/resources/resources/messages/error.properties @@ -21,6 +21,7 @@ 11017=Failed to retrieve certificate 11018=Given Alias contains no private key 11019=Signature was created for wrong certificate +11020=Failed to process PDF document. Reason: {0} 13001=Invalid Configuration Objects 13002=Given certificate is invalid diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java index 9b2a8d79..bcf04611 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; import at.gv.egiz.pdfas.common.exceptions.ErrorConstants; import at.gv.egiz.pdfas.common.exceptions.PDFASError; +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.exceptions.PdfAsMOAException; import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException; import at.gv.egiz.pdfas.lib.impl.status.OperationStatus; @@ -42,6 +43,10 @@ public class ErrorExtractor implements ErrorConstants { } else { return new PDFASError(code, e); } + + } else if(e instanceof PdfAsException) { + return new PDFASError(11020, e.getMessage(), e); + } // TODO: Handle more exceptions diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java index 47e46bcf..22c6c9a1 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java @@ -400,6 +400,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants, } catch (final Throwable e) { logger.warn("process", e); throw ErrorExtractor.searchPdfAsError(e, status); + } } else if (request.needSignature()) { request.setNeedSignature(false); |