Commit 48e06673 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when genomeId is invalid proper error message is returned

parent b2b9808d
......@@ -491,7 +491,7 @@ public abstract class BaseRestImpl {
return result;
}
protected Integer parseInteger(Object value) throws QueryException {
protected Integer parseInteger(Object value, String fieldName) throws QueryException {
if (value instanceof Integer) {
return (Integer) value;
} else if (value instanceof Double) {
......@@ -506,12 +506,16 @@ public abstract class BaseRestImpl {
try {
return Integer.parseInt((String) value);
} catch (NumberFormatException e) {
throw new QueryException("Invalid integer value: " + value);
throw new QueryException("Invalid " + fieldName + " value: " + value);
}
}
} else {
throw new QueryException("Invalid integer value: " + value);
throw new QueryException("Invalid " + fieldName + " value: " + value);
}
}
protected Integer parseInteger(Object value) throws QueryException {
return parseInteger(value, "integer");
}
}
......@@ -256,8 +256,9 @@ public class ReferenceGenomeRestImpl extends BaseRestImpl {
if (!getUserService().userHasPrivilege(token, PrivilegeType.MANAGE_GENOMES)) {
throw new SecurityException("Access denied");
}
int id = Integer.parseInt(genomeId);
int id = parseInteger(genomeId, "genomeId");
try {
ReferenceGenome genome = referenceGenomeService.getReferenceGenomeById(id, token);
String name = getFirstValue(formData.get("name"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment