diff --git a/src/main/java/org/traccar/web/server/model/DataServiceImpl.java b/src/main/java/org/traccar/web/server/model/DataServiceImpl.java index 5d53fe15..17c872b1 100644 --- a/src/main/java/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/main/java/org/traccar/web/server/model/DataServiceImpl.java @@ -1086,11 +1086,19 @@ public String sendCommand(Command command) throws AccessDeniedException { sendCommand.invoke(activeDevice, backendCommand); } } - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException - | IllegalAccessException | InstantiationException | JsonProcessingException e) { + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException + | InstantiationException | JsonProcessingException e) { log("Unable to invoke command through reflection", e); result.put("success", false); result.put("reason", e.getClass().getName() + ": " + e.getLocalizedMessage()); + } catch (InvocationTargetException ite) { + log("Error invoking command through reflection", ite); + result.put("success", false); + if (ite.getCause() == null) { + result.put("reason", ite.getClass().getName() + ": " + ite.getLocalizedMessage()); + } else { + result.put("reason", ite.getCause().getClass().getName() + ": " + ite.getCause().getLocalizedMessage()); + } } try {