feat: better error message
This commit is contained in:
@@ -13,6 +13,9 @@ import fr.titionfire.ffsaf.net2.request.SReqClub;
|
||||
import fr.titionfire.ffsaf.rest.data.DeskMember;
|
||||
import fr.titionfire.ffsaf.rest.data.RenewAffData;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleClubList;
|
||||
import fr.titionfire.ffsaf.rest.exception.DBadRequestException;
|
||||
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
||||
import fr.titionfire.ffsaf.rest.exception.DNotFoundException;
|
||||
import fr.titionfire.ffsaf.rest.from.FullClubForm;
|
||||
import fr.titionfire.ffsaf.rest.from.PartClubForm;
|
||||
import fr.titionfire.ffsaf.utils.*;
|
||||
@@ -26,9 +29,6 @@ import io.smallrye.mutiny.Uni;
|
||||
import io.smallrye.mutiny.unchecked.Unchecked;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
import jakarta.ws.rs.ForbiddenException;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||
import org.hibernate.reactive.mutiny.Mutiny;
|
||||
@@ -105,7 +105,7 @@ public class ClubService {
|
||||
.call(result -> query.count().invoke(result::setResult_count))
|
||||
.call(result -> query.pageCount()
|
||||
.invoke(Unchecked.consumer(pages -> {
|
||||
if (page > pages) throw new BadRequestException();
|
||||
if (page > pages) throw new DBadRequestException("Page out of range");
|
||||
}))
|
||||
.invoke(result::setPage_count))
|
||||
.call(result -> query.page(Page.of(page, limit)).list()
|
||||
@@ -124,7 +124,7 @@ public class ClubService {
|
||||
public Uni<ClubModel> getOfUser(JsonWebToken idToken) {
|
||||
return combRepository.find("userId = ?1", idToken.getSubject()).firstResult().invoke(Unchecked.consumer(m -> {
|
||||
if (m == null || m.getClub() == null)
|
||||
throw new NotFoundException("Club not found");
|
||||
throw new DNotFoundException("Club non trouvé");
|
||||
}))
|
||||
.map(MembreModel::getClub)
|
||||
.call(club -> Mutiny.fetch(club.getContact()));
|
||||
@@ -146,9 +146,9 @@ public class ClubService {
|
||||
|
||||
return combRepository.find("userId = ?1", idToken.getSubject()).firstResult().invoke(Unchecked.consumer(m -> {
|
||||
if (m == null || m.getClub() == null)
|
||||
throw new NotFoundException("Club not found");
|
||||
throw new DNotFoundException("Club non trouvé");
|
||||
if (!GroupeUtils.isInClubGroup(m.getClub().getId(), idToken))
|
||||
throw new ForbiddenException();
|
||||
throw new DForbiddenException();
|
||||
}))
|
||||
.map(MembreModel::getClub)
|
||||
.call(club -> Mutiny.fetch(club.getContact()))
|
||||
@@ -159,7 +159,7 @@ public class ClubService {
|
||||
try {
|
||||
club.setContact(MAPPER.readValue(form.getContact(), typeRef));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new BadRequestException();
|
||||
throw new DBadRequestException("Erreur de format des contacts");
|
||||
}
|
||||
|
||||
club.setTraining_location(form.getTraining_location());
|
||||
@@ -191,7 +191,7 @@ public class ClubService {
|
||||
try {
|
||||
m.setContact(MAPPER.readValue(input.getContact(), typeRef));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new BadRequestException();
|
||||
throw new DBadRequestException("Erreur de format des contacts");
|
||||
}
|
||||
}
|
||||
return Panache.withTransaction(() -> repository.persist(m));
|
||||
|
||||
Reference in New Issue
Block a user