diff --git a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/ResponseSerializer.java b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/ResponseSerializer.java index 539483dcc8..cd01cddc1b 100644 --- a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/ResponseSerializer.java +++ b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/ResponseSerializer.java @@ -47,6 +47,8 @@ public JsonElement serialize(LwM2mResponse src, Type typeOfSrc, JsonSerializatio element.add("location", context.serialize(((CreateResponse) src).getLocation())); } } + if (src.isFailure() && src.getErrorMessage() != null && !src.getErrorMessage().isEmpty()) + element.addProperty("errormessage", src.getErrorMessage()); return element; } diff --git a/leshan-server-demo/src/main/resources/webapp/js/helper-services.js b/leshan-server-demo/src/main/resources/webapp/js/helper-services.js index 3c8f359f5a..bc63cb17a2 100644 --- a/leshan-server-demo/src/main/resources/webapp/js/helper-services.js +++ b/leshan-server-demo/src/main/resources/webapp/js/helper-services.js @@ -20,23 +20,26 @@ myModule.factory('helper', ["$filter", function($filter) { var serviceInstance = {}; serviceInstance.handleResponse = function (response, lwm2mNode, successCallback) { - lwm2mNode.date = new Date(); + lwm2mNode.date = new Date(); var formattedDate = $filter('date')(lwm2mNode.date, 'HH:mm:ss.sss'); if (!response.valid){ - lwm2mNode.status = "INVALID"; + lwm2mNode.status = "INVALID"; }else if (response.success){ - lwm2mNode.status = "SUCCESS"; + lwm2mNode.status = "SUCCESS"; }else { - lwm2mNode.status = "ERROR"; + lwm2mNode.status = "ERROR"; } - + if (response.valid) - lwm2mNode.tooltip = formattedDate + "
" + response.status ; + lwm2mNode.tooltip = formattedDate + "
" + response.status ; else - lwm2mNode.tooltip = formattedDate + "
Not LWM2M Code
" + response.status; + lwm2mNode.tooltip = formattedDate + "
Not LWM2M Code
" + response.status; + if (response.errormessage) + lwm2mNode.tooltip = lwm2mNode.tooltip + "
" + response.errormessage; + if (successCallback && response.success) { - successCallback(formattedDate); + successCallback(formattedDate); } }; return serviceInstance;