aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java31
1 files changed, 30 insertions, 1 deletions
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 90a4e9e8..8c2451e3 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
@@ -1,11 +1,18 @@
package at.gv.egiz.pdfas.lib.impl;
+import org.slf4j.Logger;
+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.PdfAsMOAException;
import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
public class ErrorExtractor implements ErrorConstants {
+ private static final Logger logger = LoggerFactory
+ .getLogger(ErrorExtractor.class);
+
private static final int MAX_CAUSE_DEPTH = 30;
private static PDFASError convertPdfAsError(Throwable e) {
@@ -16,7 +23,27 @@ public class ErrorExtractor implements ErrorConstants {
} else {
return new PDFASError(ex.getCode(), e);
}
- } // TODO: Handle more exceptions
+ } else if(e instanceof PdfAsMOAException) {
+ PdfAsMOAException ex = (PdfAsMOAException) e;
+ int code = -1;
+ String errorInfo = ex.getErrorResponse();
+
+ if(ex.getErrorCode() != null && !ex.getErrorCode().isEmpty()) {
+ try {
+ code = Integer.parseInt(ex.getErrorCode());
+ } catch(NumberFormatException numfo) {
+ logger.warn("Failed to convert MOA ErrorCode: " + ex.getErrorCode(), e);
+ }
+ }
+
+ if (errorInfo != null) {
+ return new PDFASError(code, errorInfo, e);
+ } else {
+ return new PDFASError(code, e);
+ }
+ }
+
+ // TODO: Handle more exceptions
return null;
}
@@ -60,6 +87,8 @@ public class ErrorExtractor implements ErrorConstants {
return err;
}
+ logger.info("Cannot extract correct failure code from: ", e);
+
return new PDFASError(ERROR_GENERIC, e);
}
}