Java, Jersey
@GET
@Path("/path1")
public String getFunction(
@QueryParam("param1") Integer intParam1
) {
...
}
send get request
How to process this errors? I want to catch the error and throw another (my) error
Java, Jersey
@GET
@Path("/path1")
public String getFunction(
@QueryParam("param1") Integer intParam1
) {
...
}
send get request
How to process this errors? I want to catch the error and throw another (my) error
https://java.net/jira/browse/JERSEY-1263
@GET
public String get(@QueryParam("count") int count, @ErrorParam Map<String, String> errors) {
if (!errors.isEmpty()) {
throw new WebApplicationException(...whatever response you want to generate...);
}
... do whatever you want to do if parameters are fine ...
}
Try the following.
@GET
@Path("/path1")
public String getFunction(
@QueryParam("param1") String intParam1Str
) {
Integer intParam1 = null;
try {
intParam1 = Integer.parseInt(intParam1Str");
} catch (Exception e) {
//do whatever you want
}
}
This is because the number you are passing in:
1222534625474
is larger than the largest integer value java can handle: 2^31-1 or 2147483648.
Try setting the parameter type to long:
@GET
@Path("/path1")
public String getFunction(
@QueryParam("param1") Long intParam1
) {
...
}