use of org.ovirt.engine.api.utils.InvalidValueException in project ovirt-engine by oVirt.
the class IOExceptionMapper method toResponse.
@Override
public Response toResponse(IOException exception) {
// Check if the cause of the exception is an invalid value, and generate a specific error message:
Throwable cause = exception.getCause();
if (cause instanceof InvalidValueException) {
Fault fault = new Fault();
fault.setReason("Invalid value");
fault.setDetail(cause.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(fault).build();
}
// the request:
try {
log.error("IO exception while processing \"{}\" request for path \"{}\"", request.getMethod(), uriInfo.getPath());
log.error("Exception", exception);
UsageFinder finder = new UsageFinder();
return Response.status(Status.BAD_REQUEST).entity(finder.getUsageMessage(uriInfo, request)).build();
} catch (Exception error) {
throw new WebApplicationException(error, Response.status(Status.INTERNAL_SERVER_ERROR).build());
}
}
use of org.ovirt.engine.api.utils.InvalidValueException in project ovirt-engine by oVirt.
the class V3IOExceptionMapper method toResponse.
@Override
public Response toResponse(IOException exception) {
// Check if the cause of the exception is an invalid value, and generate a specific error message:
Throwable cause = exception.getCause();
if (cause instanceof InvalidValueException) {
V3Fault fault = new V3Fault();
fault.setReason("Invalid value");
fault.setDetail(cause.getMessage());
return Response.status(Status.BAD_REQUEST).entity(fault).build();
}
// the request:
try {
log.error("IO exception while processing \"{}\" request for path \"{}\"", request.getMethod(), uriInfo.getPath());
log.error("Exception", exception);
V3UsageFinder finder = new V3UsageFinder();
V3UsageMessage usage = finder.getUsageMessage(uriInfo, request);
return Response.status(Status.BAD_REQUEST).entity(usage).build();
} catch (Exception error) {
throw new WebApplicationException(error, Response.status(Status.INTERNAL_SERVER_ERROR).build());
}
}
Aggregations