feat: send one of an error message during edits if otherwise squashed by LimitExtent (#2246)

* feat: send one of an error message during edits if otherwise squashed by LimitExtent

* no region is not ingorable
This commit is contained in:
Jordan
2023-06-12 11:14:24 +01:00
committed by GitHub
parent ed128797ec
commit dae6c69e54
5 changed files with 110 additions and 91 deletions

View File

@ -14,6 +14,7 @@ public class FaweException extends RuntimeException {
private final Component message;
private final Type type;
private final boolean ignorable;
/**
* New instance. Defaults to {@link FaweException.Type#OTHER}.
@ -33,8 +34,19 @@ public class FaweException extends RuntimeException {
* New instance of a given {@link FaweException.Type}
*/
public FaweException(Component reason, Type type) {
this(reason, type, false);
}
/**
* New instance of a given {@link FaweException.Type}
*
* @param ignorable if an edit can continue if this exception is caught, e.g. by {@link com.fastasyncworldedit.core.extent.LimitExtent}
* @since TODO
*/
public FaweException(Component reason, Type type, boolean ignorable) {
this.message = reason;
this.type = type;
this.ignorable = ignorable;
}
@Override
@ -55,6 +67,15 @@ public class FaweException extends RuntimeException {
return type;
}
/**
* If an edit can continue if this exception is caught, e.g. by {@link com.fastasyncworldedit.core.extent.LimitExtent}
*
* @since TODO
*/
public boolean ignorable() {
return ignorable;
}
public static FaweException get(Throwable e) {
if (e instanceof FaweException) {
return (FaweException) e;