mirror of
https://codeberg.org/PGPainless/cert-d-pgpainless.git
synced 2024-12-22 13:17:58 +01:00
Add exit codes for some failure modes
This commit is contained in:
parent
d8a060d0df
commit
76a5a91fe0
2 changed files with 10 additions and 2 deletions
|
@ -42,11 +42,14 @@ public class PGPCertDCli {
|
||||||
|
|
||||||
static PGPainlessCertD certificateDirectory;
|
static PGPainlessCertD certificateDirectory;
|
||||||
|
|
||||||
|
// https://www.cyberciti.biz/faq/linux-bash-exit-status-set-exit-statusin-bash/
|
||||||
|
public static final int EXIT_CODE_NOT_A_STORE = 30;
|
||||||
|
|
||||||
private int executionStrategy(CommandLine.ParseResult parseResult) {
|
private int executionStrategy(CommandLine.ParseResult parseResult) {
|
||||||
try {
|
try {
|
||||||
initStore();
|
initStore();
|
||||||
} catch (NotAStoreException | SQLException e) {
|
} catch (NotAStoreException | SQLException e) {
|
||||||
return -1;
|
return EXIT_CODE_NOT_A_STORE;
|
||||||
}
|
}
|
||||||
return new CommandLine.RunLast().execute(parseResult);
|
return new CommandLine.RunLast().execute(parseResult);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,10 @@ public class Get implements Runnable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Get.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Get.class);
|
||||||
|
|
||||||
|
// https://www.cyberciti.biz/faq/linux-bash-exit-status-set-exit-statusin-bash/
|
||||||
|
public static final int EXIT_CODE_NO_SUCH_ELEMENT = 2;
|
||||||
|
public static final int EXIT_CODE_IO_ERROR = 5;
|
||||||
|
|
||||||
@CommandLine.Option(names = {"-a", "--armor"})
|
@CommandLine.Option(names = {"-a", "--armor"})
|
||||||
boolean armor = false;
|
boolean armor = false;
|
||||||
|
|
||||||
|
@ -60,9 +64,10 @@ public class Get implements Runnable {
|
||||||
|
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
LOGGER.debug("Certificate not found.", e);
|
LOGGER.debug("Certificate not found.", e);
|
||||||
|
System.exit(EXIT_CODE_NO_SUCH_ELEMENT);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("IO Error", e);
|
LOGGER.error("IO Error", e);
|
||||||
System.exit(-1);
|
System.exit(EXIT_CODE_IO_ERROR);
|
||||||
} catch (BadDataException e) {
|
} catch (BadDataException e) {
|
||||||
LOGGER.error("Certificate file contains bad data.", e);
|
LOGGER.error("Certificate file contains bad data.", e);
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
|
Loading…
Reference in a new issue