Skip to content

Commit

Permalink
add details to error messages (IQSS#10813)
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers authored Sep 4, 2024
1 parent 92d3839 commit 05962ef
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang3.StringUtils;

/**
* Catches all types of web application exceptions like NotFoundException, etc etc and handles them properly.
*/
Expand Down Expand Up @@ -49,7 +51,14 @@ public Response toResponse(WebApplicationException ex) {
} else if ((ex.getMessage() + "").toLowerCase().startsWith("no permission to download file")) {
jrb.message(BundleUtil.getStringFromBundle("access.api.exception.metadata.restricted.no.permission"));
} else {
jrb.message("Bad Request. The API request cannot be completed with the parameters supplied. Please check your code for typos, or consult our API guide at http://guides.dataverse.org.");
String msg = ex.getMessage();
msg = StringUtils.isEmpty(msg)
? "Bad Request. The API request cannot be completed with the parameters supplied. Please check your code for typos, or consult our API guide at http://guides.dataverse.org."
: "Bad Request. The API request cannot be completed with the parameters supplied. Details: "
+ msg
+ " - please check your code for typos, or consult our API guide at http://guides.dataverse.org.";

jrb.message(msg);
jrb.request(request);
}
break;
Expand Down

0 comments on commit 05962ef

Please sign in to comment.