Skip to content

Commit 6d0a397

Browse files
added the BadRequestResult
1 parent 2666619 commit 6d0a397

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

commands/src/main/java/com/wizardlybump17/wlib/command/result/CommandResult.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public interface CommandResult<T> {
8686
return new ConflictResult<>(lastInputIndex, lastNode);
8787
}
8888

89+
static <T> @NotNull BadRequestResult<T> badRequest(int lastInputIndex, @NotNull CommandNode<?> lastNode) {
90+
return new BadRequestResult<>(lastInputIndex, lastNode);
91+
}
92+
8993
//with context
9094

9195
static <T> @NotNull SuccessResult<T> successful(@NotNull CommandContext context, @Nullable T data) {
@@ -123,4 +127,8 @@ public interface CommandResult<T> {
123127
static <T> @NotNull ConflictResult<T> conflict(@NotNull CommandContext context) {
124128
return conflict(context.lastInputIndex(), context.lastNode());
125129
}
130+
131+
static <T> @NotNull BadRequestResult<T> badRequest(@NotNull CommandContext context) {
132+
return badRequest(context.lastInputIndex(), context.lastNode());
133+
}
126134
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.wizardlybump17.wlib.command.result.error;
2+
3+
import com.wizardlybump17.wlib.command.node.CommandNode;
4+
import org.jetbrains.annotations.NotNull;
5+
6+
public record BadRequestResult<T>(int lastInputIndex, @NotNull CommandNode<?> lastNode) implements UnsuccessResult<T> {
7+
8+
public static final @NotNull String ID = "WLib:Error/BadRequest";
9+
10+
@Override
11+
public @NotNull String id() {
12+
return ID;
13+
}
14+
}

0 commit comments

Comments
 (0)