return just an error message from Section.tryParse

This commit is contained in:
kageru 2020-07-04 00:44:44 +02:00
parent 50f1ca6757
commit d38a063b41
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -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));
}
}