mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 08:08:34 +00:00
Improve exceptions (#1256)
- Kick more exceptions further up the pipeline to be more likely to be shown to player - Try to avoid lots of console spamming when it's the same error multiple times - Allow parsing of FaweExceptions during commands to better give information to players
This commit is contained in:
@ -5,7 +5,7 @@ import com.fastasyncworldedit.core.configuration.Caption;
|
||||
public class FaweBlockBagException extends FaweException {
|
||||
|
||||
public FaweBlockBagException() {
|
||||
super(Caption.of("fawe.error.worldedit.some.fails.blockbag"));
|
||||
super(Caption.of("fawe.error.worldedit.some.fails.blockbag"), Type.BLOCK_BAG);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
package com.fastasyncworldedit.core.internal.exception;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
|
||||
public class FaweChunkLoadException extends FaweException {
|
||||
|
||||
public FaweChunkLoadException() {
|
||||
super(Caption.of("fawe.cancel.worldedit.failed.load.chunk"));
|
||||
}
|
||||
|
||||
}
|
@ -13,13 +13,28 @@ public class FaweException extends RuntimeException {
|
||||
public static final FaweException _disableQueue = new FaweException("disableQueue");
|
||||
|
||||
private final Component message;
|
||||
private final Type type;
|
||||
|
||||
/**
|
||||
* New instance. Defaults to {@link FaweException.Type#OTHER}.
|
||||
*/
|
||||
public FaweException(String reason) {
|
||||
this(TextComponent.of(reason));
|
||||
}
|
||||
|
||||
/**
|
||||
* New instance. Defaults to {@link FaweException.Type#OTHER}.
|
||||
*/
|
||||
public FaweException(Component reason) {
|
||||
this(reason, Type.OTHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* New instance of a given {@link FaweException.Type}
|
||||
*/
|
||||
public FaweException(Component reason, Type type) {
|
||||
this.message = reason;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,6 +46,14 @@ public class FaweException extends RuntimeException {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link FaweException.Type}
|
||||
* @return the {@link FaweException.Type}
|
||||
*/
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static FaweException get(Throwable e) {
|
||||
if (e instanceof FaweException) {
|
||||
return (FaweException) e;
|
||||
@ -52,4 +75,19 @@ public class FaweException extends RuntimeException {
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
MANUAL,
|
||||
NO_REGION,
|
||||
OUTSIDE_REGION,
|
||||
MAX_CHECKS,
|
||||
MAX_CHANGES,
|
||||
LOW_MEMORY,
|
||||
MAX_ENTITIES,
|
||||
MAX_TILES,
|
||||
MAX_ITERATIONS,
|
||||
BLOCK_BAG,
|
||||
CHUNK,
|
||||
OTHER
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user