Skip to content

Commit 3b736e3

Browse files
PVQ-4362 External actions - If an external action fails, log the error with the corresponding error code (add errors into config.json)
- reworked where exit codes are places - added definition of error codes and messages to config.json (Desktop can parse this dictionary and use it for user friendly error messaging)
1 parent 8125b68 commit 3b736e3

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@
142142
"type": "file_path",
143143
"value": ""
144144
}
145-
]
145+
],
146+
"errors": {
147+
"101": "Unforseen error happened. More info in logs."
148+
}
146149
}
147150
]
148151
}

src/main/java/net/pdfix/App.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ public class App {
1616
private static String VERSION = "1.0.0";
1717
private static String APP_NAME = "Validate PDF Accessibility";
1818

19-
// Success codes: 0-100 for object counts
20-
// Error codes: 101+ to avoid conflict with object counts
21-
private static final int MAX_EXIT_CODE = 100;
22-
private static final int ERROR_GENERAL = 101;
23-
2419
private static void displayVersion() {
2520
Properties properties = new Properties();
2621
try {
@@ -174,10 +169,11 @@ public int compare(File f1, File f2) {
174169
System.out.println("===============================================================================\n");
175170
}
176171
System.out.println("Process complete");
177-
System.exit(Math.min(count, MAX_EXIT_CODE));
172+
System.exit(Math.min(count, ExitCodes.MAX_SUCCESS));
178173
} catch (Exception e) {
174+
System.err.println(ExitCodes.GENERAL_MESSAGE);
179175
System.err.println(e.getLocalizedMessage());
180-
System.exit(ERROR_GENERAL);
176+
System.exit(ExitCodes.GENERAL_ERROR);
181177
}
182178
}
183179
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Defines all system exit codes for the application.
3+
*/
4+
public class ExitCodes {
5+
/** Biggest code for successful execution. Exit code 0-100 represents number of duplicate MCIDs. */
6+
public static final int MAX_SUCCESS = 100;
7+
8+
/** Uncaught General error. Out of 0-100 range. */
9+
public static final int GENERAL_ERROR = 101;
10+
11+
/** General error message for console. */
12+
public static final String GENERAL_MESSAGE = "Unforseen error happened. More info in logs.";
13+
}

0 commit comments

Comments
 (0)