fix #2839 Adjust API response to conditionally include exception messages based on configuration.
This commit is contained in:
parent
59dbbd602b
commit
ec6385766e
1 changed files with 10 additions and 2 deletions
|
@ -102,8 +102,16 @@ public class SearchEngineApiManager extends BaseApiManager {
|
|||
throw new WebApiException(HttpServletResponse.SC_FORBIDDEN, "Invalid session.");
|
||||
});
|
||||
} catch (final WebApiException e) {
|
||||
logger.debug("Failed to access to Web API.", e);
|
||||
response.sendError(e.getStatusCode(), e.getMessage());
|
||||
String message;
|
||||
if (Constants.TRUE.equalsIgnoreCase(ComponentUtil.getFessConfig().getApiJsonResponseExceptionIncluded())) {
|
||||
logger.warn("Failed to access to Web API.", e);
|
||||
message = e.getMessage();
|
||||
} else {
|
||||
final String errorCode = UUID.randomUUID().toString();
|
||||
message = "[" + errorCode + "] Failed to access to Web API.";
|
||||
logger.warn(message, e);
|
||||
}
|
||||
response.sendError(e.getStatusCode(), message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue