X-Git-Url: http://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fapi%2Fcli%2FCommandRuntimeException.java;fp=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fapi%2Fcli%2FCommandRuntimeException.java;h=52c033433d69343736eec3d6b14ad1f6f558fb41;hp=0000000000000000000000000000000000000000;hb=40f2d6712d120dd62a42b7db3a6f074ce49c83d4;hpb=c7b612ca9bd7df43b0bec37c8abcae846587c978 diff --git a/org.argeo.cms/src/org/argeo/api/cli/CommandRuntimeException.java b/org.argeo.cms/src/org/argeo/api/cli/CommandRuntimeException.java new file mode 100644 index 000000000..52c033433 --- /dev/null +++ b/org.argeo.cms/src/org/argeo/api/cli/CommandRuntimeException.java @@ -0,0 +1,35 @@ +package org.argeo.api.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; + } + +}