Skip to content

Commit

Permalink
wrap whole async task in try catch....
Browse files Browse the repository at this point in the history
  • Loading branch information
addshore committed Feb 27, 2019
1 parent cfaf182 commit 3063898
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ public void run() {

@Override
protected Object call() throws Exception {
try{
processTask();
} catch( JSONException | IOException exception ) {
appendMessage("Something went wrong while running the task.");
appendMessage("ERROR: " + exception.getMessage() );
appendMessage("Task may not have completely finished.");
}

appendDebugMessage("Closing exiftool");
exifTool.close();

return null;
}

private void processTask() throws IOException, JSONException {
// Find all album json files
appendMessage( "Looking for albums..." );
File albumDir = new File( dir.toPath().toString() + File.separator + "album" );
Expand All @@ -88,7 +103,7 @@ public boolean accept(File dir, String filename)
// Stop if we detected no JSON but did find HTML
if( albumJsonFiles.length == 0 && albumHtmlFiles.length != 0 ) {
appendMessage("This program currently only works with the JSON facebook downloads");
return null;
return;
}

int statProcessedImages = 0;
Expand Down Expand Up @@ -138,18 +153,13 @@ public boolean accept(File dir, String filename)
}
}

appendDebugMessage("Closing exiftool");

exifTool.close();

appendMessage("-------------------------------------------------");
appendMessage("Task complete");
appendMessage("Images processed: " + statProcessedImages);
appendMessage("Images failed: " + statFailedImages);
if(statFailedImages != 0) {
appendMessage("See the output for more details...");
}

return null;
}

private void processFile( JSONObject photoData ) throws JSONException, IOException {
Expand Down

0 comments on commit 3063898

Please sign in to comment.