X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.core%2Fsrc%2Forg%2Fargeo%2Fcli%2FCommandRuntimeException.java;fp=org.argeo.core%2Fsrc%2Forg%2Fargeo%2Fcli%2FCommandRuntimeException.java;h=68b9a18cf0cfd156f11313bac3448c284dc61b53;hb=905c6bcd909d84c6e980994d9eeed22a0bf237af;hp=0000000000000000000000000000000000000000;hpb=00d7430765eba4f0c13f8300515a679a808bc7b1;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.core/src/org/argeo/cli/CommandRuntimeException.java b/org.argeo.core/src/org/argeo/cli/CommandRuntimeException.java new file mode 100644 index 000000000..68b9a18cf --- /dev/null +++ b/org.argeo.core/src/org/argeo/cli/CommandRuntimeException.java @@ -0,0 +1,35 @@ +package org.argeo.cli; + +import java.util.List; + +/** {@link RuntimeException} referring during a command run. */ +public class CommandRuntimeException extends RuntimeException { + private static final long serialVersionUID = 5595999301269377128L; + + private final DescribedCommand command; + private final List arguments; + + public CommandRuntimeException(Throwable e, DescribedCommand command, List arguments) { + this(null, e, command, arguments); + } + + public CommandRuntimeException(String message, DescribedCommand command, List arguments) { + this(message, null, command, arguments); + } + + public CommandRuntimeException(String message, Throwable e, DescribedCommand command, List arguments) { + super(message == null ? "(" + command.getClass().getName() + " " + arguments.toString() + ")" + : message + " (" + command.getClass().getName() + " " + arguments.toString() + ")", e); + this.command = command; + this.arguments = arguments; + } + + public DescribedCommand getCommand() { + return command; + } + + public List getArguments() { + return arguments; + } + +}