1 package dev.sympho.modular_commands.api.exception;
2
3 import dev.sympho.modular_commands.api.command.result.CommandResult;
4
5 /**
6 * Exception that indicates that command execution finished.
7 *
8 * <p>Throwing it from within an execution handler has the same effect as
9 * returning the contained result.
10 *
11 * <p>Note that, to minimize the runtime overhead of using this exception,
12 * it does <i>not</i> record the stack trace or suppressed exceptions.
13 *
14 * @version 1.0
15 * @since 1.0
16 * @apiNote This exception is given as an alternative to directly returning the
17 * result for cases when some early completion occurs deep into the
18 * call stack, where it would be impractical to return a result normally.
19 * Returning the result directly is preferrable whenever possible.
20 */
21 public class ResultException extends CommandException {
22
23 private static final long serialVersionUID = 8910758904031220818L;
24
25 /** The failure. */
26 private final transient CommandResult result;
27
28 /**
29 * Creates a new instance.
30 *
31 * @param result The result of execution.
32 */
33 public ResultException( final CommandResult result ) {
34
35 // Minimize runtime overhead
36 super( "", null, false, false );
37
38 this.result = result;
39
40 }
41
42 /**
43 * Retrieves the execution result.
44 *
45 * @return The execution result.
46 */
47 public CommandResult getResult() {
48
49 return result;
50
51 }
52
53 }