2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
package sop.exception;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public abstract class SOPGPException extends RuntimeException {
|
2021-07-15 16:55:13 +02:00
|
|
|
|
|
|
|
public SOPGPException() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
public SOPGPException(String message) {
|
|
|
|
super(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SOPGPException(Throwable e) {
|
|
|
|
super(e);
|
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public SOPGPException(String message, Throwable cause) {
|
|
|
|
super(message, cause);
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract int getExitCode();
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
public static class NoSignature extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 3;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public NoSignature() {
|
|
|
|
super("No verifiable signature found.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class UnsupportedAsymmetricAlgo extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 13;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public UnsupportedAsymmetricAlgo(String message, Throwable e) {
|
|
|
|
super(message, e);
|
|
|
|
}
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
public UnsupportedAsymmetricAlgo(Throwable e) {
|
|
|
|
super(e);
|
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class CertCannotEncrypt extends SOPGPException {
|
|
|
|
public static final int EXIT_CODE = 17;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public CertCannotEncrypt(String message, Throwable cause) {
|
|
|
|
super(message, cause);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public static class CertCannotSign extends Exception {
|
2021-07-15 16:55:13 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class MissingArg extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 19;
|
|
|
|
|
|
|
|
public MissingArg(String s) {
|
|
|
|
super(s);
|
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class IncompleteVerification extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 23;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public IncompleteVerification(String message) {
|
|
|
|
super(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class CannotDecrypt extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 29;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class PasswordNotHumanReadable extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 31;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class UnsupportedOption extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 37;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public UnsupportedOption(String message) {
|
|
|
|
super(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public UnsupportedOption(String message, Throwable cause) {
|
|
|
|
super(message, cause);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class BadData extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 41;
|
|
|
|
|
|
|
|
public BadData(Throwable e) {
|
|
|
|
super(e);
|
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public BadData(String message, BadData badData) {
|
|
|
|
super(message, badData);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ExpectedText extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 53;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class OutputExists extends SOPGPException {
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public static final int EXIT_CODE = 59;
|
|
|
|
|
|
|
|
public OutputExists(String message) {
|
|
|
|
super(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public static class MissingInput extends SOPGPException {
|
2021-07-15 16:55:13 +02:00
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public static final int EXIT_CODE = 61;
|
|
|
|
|
|
|
|
public MissingInput(String message, Throwable cause) {
|
|
|
|
super(message, cause);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public static class KeyIsProtected extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 67;
|
|
|
|
|
|
|
|
public KeyIsProtected() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyIsProtected(String message, Throwable cause) {
|
|
|
|
super(message, cause);
|
|
|
|
}
|
2021-07-15 16:55:13 +02:00
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
@Override
|
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public static class UnsupportedSubcommand extends SOPGPException {
|
2021-07-15 16:55:13 +02:00
|
|
|
|
|
|
|
public static final int EXIT_CODE = 69;
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
public UnsupportedSubcommand(String message) {
|
|
|
|
super(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class UnsupportedSpecialPrefix extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 71;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class AmbiguousInput extends SOPGPException {
|
|
|
|
|
|
|
|
public static final int EXIT_CODE = 73;
|
|
|
|
|
2021-08-19 16:44:29 +02:00
|
|
|
public AmbiguousInput(String message) {
|
|
|
|
super(message);
|
|
|
|
}
|
|
|
|
|
2021-07-19 18:20:52 +02:00
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public int getExitCode() {
|
|
|
|
return EXIT_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|