return just an error message from Section.tryParse
This commit is contained in:
parent
50f1ca6757
commit
d38a063b41
@ -13,9 +13,9 @@ public enum Section {
|
||||
DAIRY,
|
||||
HYGIENE;
|
||||
|
||||
public static Either<Resp, Section> tryParse(String catName) {
|
||||
public static Either<String, Section> tryParse(String catName) {
|
||||
return Stream.of(Section.values())
|
||||
.find(c -> c.name().equalsIgnoreCase(catName))
|
||||
.toEither(Resp.BAD_REQUEST.apply("Category “%s” not found".formatted(catName)));
|
||||
.toEither("Category “%s” not found".formatted(catName));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user