fix(error): update error mapper
This commit is contained in:
parent
4e9686d6a7
commit
1b39c438bf
@ -2,18 +2,20 @@ package fr.titionfire.ffsaf.rest.exception;
|
|||||||
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
import jakarta.ws.rs.ext.ExceptionMapper;
|
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
|
||||||
import jakarta.ws.rs.ext.Provider;
|
import org.jboss.resteasy.reactive.server.UnwrapException;
|
||||||
|
|
||||||
@Provider
|
import java.util.concurrent.CompletionException;
|
||||||
public class DetailExceptionMapper implements ExceptionMapper<DetailException> {
|
|
||||||
|
|
||||||
@Override
|
@UnwrapException({CompletionException.class, RuntimeException.class})
|
||||||
public Response toResponse(DetailException e) {
|
public class DetailExceptionMapper{
|
||||||
|
|
||||||
|
@ServerExceptionMapper
|
||||||
|
public Response mapException(DetailException e) {
|
||||||
|
System.out.println("DetailExceptionMapper: " + e.getMessage());
|
||||||
return Response.status(e.getStatus())
|
return Response.status(e.getStatus())
|
||||||
.entity(e.getMessage())
|
.entity(e.getMessage())
|
||||||
.type(MediaType.TEXT_PLAIN_TYPE)
|
.type(MediaType.TEXT_PLAIN_TYPE)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import {useLoadingSwitcher} from "../../../hooks/useLoading.jsx";
|
import {useLoadingSwitcher} from "../../../hooks/useLoading.jsx";
|
||||||
import {apiAxios} from "../../../utils/Tools.js";
|
import {apiAxios, errFormater} from "../../../utils/Tools.js";
|
||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import imageCompression from "browser-image-compression";
|
import imageCompression from "browser-image-compression";
|
||||||
import {BirthDayField, CountryList, OptionField, RoleList, TextField} from "../../../components/MemberCustomFiels.jsx";
|
import {BirthDayField, CountryList, OptionField, RoleList, TextField} from "../../../components/MemberCustomFiels.jsx";
|
||||||
@ -70,7 +70,7 @@ export function InformationForm({data}) {
|
|||||||
toast.success('Profile mis à jours avec succès 🎉');
|
toast.success('Profile mis à jours avec succès 🎉');
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.log(e.response)
|
console.log(e.response)
|
||||||
toast.error('Échec de la mise à jours du profile 😕 (code: ' + e.response.status + ')');
|
toast.error(errFormater(e,'Échec de la mise à jours du profile 😕'));
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
if (setLoading)
|
if (setLoading)
|
||||||
setLoading(0)
|
setLoading(0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user