- Improve error-handling.

- Improve a log-message.
This commit is contained in:
Lampros Smyrnaios 2023-11-29 13:49:54 +02:00
parent 5a9e7228ae
commit bad9544c58
2 changed files with 6 additions and 3 deletions

View File

@ -80,8 +80,11 @@ public class PublicationsRetrieverPlugin {
File curAssignmentsDirs = new File(FileUtils.storeDocFilesDir); File curAssignmentsDirs = new File(FileUtils.storeDocFilesDir);
try { try {
if ( ! curAssignmentsDirs.mkdirs() ) // Create the subdirectory. It may return "false", in case it already exists (will not happen, unless there is problem in cleaning up of the subdirectories) or any problem occurred. if ( !curAssignmentsDirs.exists() ) {
throw new RuntimeException("Could not create the \"assignments_" + assignmentRequestCounter + "_fullTexts\" directories: \"" + FileUtils.storeDocFilesDir + "\"!"); if ( !curAssignmentsDirs.mkdirs() ) // Try to create the directory(-ies) if they don't exist. If they exist OR if sth went wrong, the result is the same: "false".
throw new RuntimeException("Could not create the \"" + currentAssignmentsSubDir + "\" directories: \"" + FileUtils.storeDocFilesDir + "\"!");
} else
logger.warn("The curAssignmentsDirs: \"" + currentAssignmentsSubDir + "\" already exist! Probably left behind by a previous execution..");
} catch (Exception e) { // Mainly a SecurityException. } catch (Exception e) { // Mainly a SecurityException.
throw new RuntimeException("Failed to create the full-texts directory for assignments_" + assignmentRequestCounter + ": " + e.getMessage()); throw new RuntimeException("Failed to create the full-texts directory for assignments_" + assignmentRequestCounter + ": " + e.getMessage());
} }

View File

@ -66,7 +66,7 @@ public class GeneralController {
String finalMsg = ""; String finalMsg = "";
if ( shouldShutdownWorker ) if ( shouldShutdownWorker )
finalMsg = "The worker has already received a \"shutdownWorker\" (which was not canceled afterwards). "; finalMsg = "The worker has already received a \"shutdownWorker\" request (which was not canceled afterwards). ";
else else
shouldShutdownWorker = true; shouldShutdownWorker = true;