[Minor] Log exceptions of StrolchSystemAction

This commit is contained in:
Robert von Burg 2018-02-20 09:47:35 +01:00
parent 0dc11c74f9
commit a2a0645f3b
1 changed files with 11 additions and 2 deletions

View File

@ -2,14 +2,18 @@ package li.strolch.runtime.privilege;
import li.strolch.privilege.handler.SystemAction;
import li.strolch.privilege.model.PrivilegeContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* {@link SystemAction} to run {@link PrivilegedRunnable} as a system user
*
*
* @author Robert von Burg <eitch@eitchnet.ch>
*/
public class StrolchSystemAction extends SystemAction {
public static final Logger logger = LoggerFactory.getLogger(StrolchSystemAction.class);
private PrivilegedRunnable runnable;
public StrolchSystemAction(PrivilegedRunnable runnable) {
@ -18,6 +22,11 @@ public class StrolchSystemAction extends SystemAction {
@Override
public void execute(PrivilegeContext privilegeContext) {
this.runnable.run(privilegeContext);
try {
this.runnable.run(privilegeContext);
} catch (Exception e) {
logger.error("Failed to execute SystemAction for " + privilegeContext.getUsername() + " due to " + e
.getMessage(), e);
}
}
}