com.genexus.ws.GXRestException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gxwrapperjakarta Show documentation
Show all versions of gxwrapperjakarta Show documentation
Core classes for the runtime used by Java and Android apps generated with GeneXus
The newest version!
package com.genexus.ws;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import com.genexus.WrapperUtils;
import jakarta.annotation.Priority;
@Provider
@Priority(2)
public class GXRestException extends Throwable implements ExceptionMapper
{
private static final long serialVersionUID = 1L;
@Override
public Response toResponse(Throwable ex)
{
int statusCode[] = {0};
String reasonPhrase = "";
boolean applicationException = false;
if (ex instanceof WebApplicationException)
{
statusCode[0] = ((WebApplicationException)ex).getResponse().getStatus();
reasonPhrase = ((WebApplicationException)ex).getResponse().getStatusInfo().getReasonPhrase();
applicationException = true;
}
String jsonString = WrapperUtils.getJsonFromRestException(statusCode, reasonPhrase, applicationException, ex);
return Response.status(statusCode[0]).entity(jsonString).type("application/json").build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy