Arakne /
Araknemu
| 1 | /* |
||
| 2 | * This file is part of Araknemu. |
||
| 3 | * |
||
| 4 | * Araknemu is free software: you can redistribute it and/or modify |
||
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
||
| 6 | * the Free Software Foundation, either version 3 of the License, or |
||
| 7 | * (at your option) any later version. |
||
| 8 | * |
||
| 9 | * Araknemu is distributed in the hope that it will be useful, |
||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 12 | * GNU Lesser General Public License for more details. |
||
| 13 | * |
||
| 14 | * You should have received a copy of the GNU Lesser General Public License |
||
| 15 | * along with Araknemu. If not, see <https://www.gnu.org/licenses/>. |
||
| 16 | * |
||
| 17 | * Copyright (c) 2017-2021 Vincent Quatrevieux |
||
| 18 | */ |
||
| 19 | |||
| 20 | package fr.quatrevieux.araknemu.game.admin.exception; |
||
| 21 | |||
| 22 | import fr.quatrevieux.araknemu.game.admin.CommandParser; |
||
| 23 | import org.checkerframework.checker.nullness.qual.NonNull; |
||
| 24 | import org.checkerframework.checker.nullness.util.NullnessUtil; |
||
| 25 | import org.checkerframework.dataflow.qual.Pure; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Exception wrapper for store the parsed command arguments |
||
| 29 | * Use {@link CommandExecutionException#getCause()} to get the real exception |
||
| 30 | */ |
||
| 31 | public final class CommandExecutionException extends CommandException { |
||
| 32 | private final CommandParser.Arguments arguments; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 33 | |||
| 34 | public CommandExecutionException(CommandParser.Arguments arguments, Throwable cause) { |
||
| 35 | 1 | super(arguments.command(), cause.getMessage() == null ? "[no message]" : cause.getMessage(), cause); |
|
| 36 | 1 | this.arguments = arguments; |
|
| 37 | 1 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Get the execution arguments |
||
| 41 | */ |
||
| 42 | public CommandParser.Arguments arguments() { |
||
| 43 | 1 | return arguments; |
|
| 44 | } |
||
| 45 | |||
| 46 | @Override |
||
| 47 | @Pure |
||
| 48 | public synchronized @NonNull Throwable getCause() { |
||
| 49 | 1 | return NullnessUtil.castNonNull(super.getCause()); |
|
| 50 | } |
||
| 51 | } |
||
| 52 |