-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add InvalidUsageException, Refactor exception handling. Release 3.0.0…
…-BETA-pre20
- Loading branch information
Showing
32 changed files
with
174 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
litecommands-core/src/dev/rollczi/litecommands/handler/exception/ExceptionHandleService.java
This file was deleted.
Oops, something went wrong.
7 changes: 5 additions & 2 deletions
7
litecommands-core/src/dev/rollczi/litecommands/handler/exception/ExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package dev.rollczi.litecommands.handler.exception; | ||
|
||
import dev.rollczi.litecommands.handler.result.ResultHandler; | ||
import dev.rollczi.litecommands.handler.result.ResultHandlerChain; | ||
import dev.rollczi.litecommands.invocation.Invocation; | ||
|
||
public interface ExceptionHandler<SENDER, E extends Throwable> { | ||
@FunctionalInterface | ||
public interface ExceptionHandler<SENDER, E extends Throwable> extends ResultHandler<SENDER, E> { | ||
|
||
void handle(Invocation<SENDER> invocation, E exception); | ||
void handle(Invocation<SENDER> invocation, E exception, ResultHandlerChain<SENDER> chain); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...dev/rollczi/litecommands/handler/exception/standard/InvocationTargetExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dev.rollczi.litecommands.handler.exception.standard; | ||
|
||
import dev.rollczi.litecommands.handler.exception.ExceptionHandler; | ||
import dev.rollczi.litecommands.handler.result.ResultHandlerChain; | ||
import dev.rollczi.litecommands.invocation.Invocation; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
|
||
public class InvocationTargetExceptionHandler<SENDER> implements ExceptionHandler<SENDER, InvocationTargetException> { | ||
|
||
@Override | ||
public void handle(Invocation<SENDER> invocation, InvocationTargetException exception, ResultHandlerChain<SENDER> chain) { | ||
Throwable cause = exception.getCause(); | ||
|
||
if (cause == null || cause.equals(exception)) { | ||
chain.resolve(invocation, exception, ReflectiveOperationException.class); | ||
return; | ||
} | ||
|
||
chain.resolve(invocation, cause); | ||
} | ||
|
||
} |
Oops, something went wrong.