Skip to content

Commit

Permalink
NXP-24680: Don't swallow exception
Browse files Browse the repository at this point in the history
NXP-24680: Don't swallow exception - more
  • Loading branch information
michaelva committed Mar 22, 2018
1 parent 63ad774 commit a5bc7b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Expand Up @@ -29,6 +29,7 @@
import org.nuxeo.ecm.automation.OperationException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.NuxeoException;
import org.nuxeo.ecm.core.event.*;
import org.nuxeo.ecm.core.event.impl.DocumentEventContext;
import org.nuxeo.ecm.core.event.impl.EventContextImpl;
Expand Down Expand Up @@ -76,7 +77,7 @@ protected void handleEvent(Event event) {
eventService.fireEvent(eventToSend);

} catch (OperationException e) {
log.warn(e);
throw new NuxeoException(e);
}
}
}
Expand Up @@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuxeo.ecm.automation.OperationContext;
import org.nuxeo.ecm.automation.OperationException;
import org.nuxeo.ecm.automation.core.Constants;
import org.nuxeo.ecm.automation.core.annotations.Context;
import org.nuxeo.ecm.automation.core.annotations.Operation;
Expand Down Expand Up @@ -69,7 +70,7 @@ public class VisionOp {
protected int maxResults;

@OperationMethod
public Blob run(Blob blob) {
public Blob run(Blob blob) throws OperationException {
if (blob == null) {
return null;
}
Expand All @@ -79,7 +80,7 @@ public Blob run(Blob blob) {
}

@OperationMethod
public BlobList run(BlobList blobs) {
public BlobList run(BlobList blobs) throws OperationException {
List<VisionResponse> results;

// Convert feature string to enum
Expand All @@ -96,7 +97,7 @@ public BlobList run(BlobList blobs) {
}
ctx.put(outputVariable, results);
} catch (IOException | GeneralSecurityException e) {
log.warn("Call to google vision API failed", e);
throw new OperationException("Call to google vision API failed", e);
}
return blobs;
}
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.nuxeo.ecm.automation.OperationException;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.NuxeoException;
import org.nuxeo.ecm.core.event.Event;
import org.nuxeo.ecm.core.event.EventService;
import org.nuxeo.ecm.core.event.impl.DocumentEventContext;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void work() {
eventService.fireEvent(eventToSend);

} catch (OperationException e) {
log.warn(e);
throw new NuxeoException("Failed to run nuxeo vision",e);
}

setStatus("Done");
Expand Down

0 comments on commit a5bc7b3

Please sign in to comment.