Skip to content

Commit

Permalink
catch runtime exception
Browse files Browse the repository at this point in the history
Issue #153
  • Loading branch information
rsoika committed Apr 20, 2021
1 parent d544a56 commit c5b23b1
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*/
public class OCRDocumentAdapter implements SignalAdapter {

public static final String OCR_ERROR = "OCR_ERROR";

private static Logger logger = Logger.getLogger(OCRDocumentAdapter.class.getName());

@Inject
Expand Down Expand Up @@ -74,7 +76,13 @@ public ItemCollection execute(ItemCollection document, ItemCollection event) thr
// extract text data....
ocrService.extractText(document, snapshotService.findSnapshot(document), null, tikaOptions);
} catch (PluginException e) {
throw new AdapterException(e.getErrorContext(), e.getErrorCode(), e.getMessage(), e);
String message="Tika OCRService - unable to extract text: " + e.getMessage();
throw new AdapterException(e.getErrorContext(), e.getErrorCode(), message, e);
} catch (RuntimeException e) {
// we catch a runtimeException to avoid dead locks in the eventLog processing
// issue #153
String message="Tika OCRService - unable to extract text: " + e.getMessage();
throw new AdapterException(OCRDocumentAdapter.class.getSimpleName(), OCR_ERROR, message, e);
}
} else {
logger.warning("unexpected TIKA_SERVICE_MODE=" + serviceMode
Expand Down

0 comments on commit c5b23b1

Please sign in to comment.