Skip to content
Snippets Groups Projects
Commit 1f3bd6bb authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Add config property for exception messages in API responses

Execption messages in API responses is disabled by default because they
can contain sensitive data. The config property
`api.expose-exception-messages` has been added and is described in the
developer documentation.
parent f1e0b96e
1 merge request!52Improve exception handling
Pipeline #8110 failed with stages
in 2 minutes and 31 seconds
package de.thm.arsnova.controller;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.Map;
public class AbstractControllerExceptionHandler {
/* Since exception messages might contain sensitive data, they are not exposed by default. */
@Value("${api.expose-error-messages:false}") private boolean exposeMessages;
protected Map<String, Object> handleException(Throwable e) {
final Map<String, Object> result = new HashMap<>();
result.put("errorType", e.getClass().getSimpleName());
result.put("errorMessage", e.getMessage());
if (exposeMessages) {
result.put("errorMessage", e.getMessage());
}
return result;
}
......
......@@ -37,6 +37,9 @@ Run the following command to download the dependencies and startup the backend w
After a few seconds the ARSnova API will be accessible at <http://localhost:8080/>.
You can adjust the amount of debug logging by changing the log levels in [log4j-dev.properties](src/main/resources/log4j-dev.properties).
Additionally, you can enable exception messages in API responses by setting the boolean property `api.expose-error-messages` in `arsnova.properties`.
## Continuous Integration
......
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