diff --git a/src/core/Param.js b/src/core/Param.js index 65416eae8..05fa11ee1 100644 --- a/src/core/Param.js +++ b/src/core/Param.js @@ -25,8 +25,10 @@ function Param(options) { * * @param {function} callback - Function with the following params: * @param {Object} callback.value - The value of the param from ROS. + * @param {function} [failedCallback] - Function when the service call failed with the following params: + * @param {string} failedCallback.error - The error message reported by ROS. */ -Param.prototype.get = function(callback) { +Param.prototype.get = function(callback, failedCallback) { var paramClient = new Service({ ros : this.ros, name : '/rosapi/get_param', @@ -40,16 +42,18 @@ Param.prototype.get = function(callback) { paramClient.callService(request, function(result) { var value = JSON.parse(result.value); callback(value); - }); + }, failedCallback); }; /** * Set the value of the param in ROS. * * @param {Object} value - The value to set param to. - * @param {function} callback - The callback function. + * @param {function} [callback] - The callback function. + * @param {function} [failedCallback] - The callback function when the service call failed. + * @param {string} failedCallback.error - The error message reported by ROS. */ -Param.prototype.set = function(value, callback) { +Param.prototype.set = function(value, callback, failedCallback) { var paramClient = new Service({ ros : this.ros, name : '/rosapi/set_param', @@ -61,15 +65,17 @@ Param.prototype.set = function(value, callback) { value : JSON.stringify(value) }); - paramClient.callService(request, callback); + paramClient.callService(request, callback, failedCallback); }; /** * Delete this parameter on the ROS server. * - * @param {function} callback - The callback function. + * @param {function} [callback] - The callback function when the service call succeeded. + * @param {function} [failedCallback] - The callback function when the service call failed. + * @param {string} failedCallback.error - The error message reported by ROS. */ -Param.prototype.delete = function(callback) { +Param.prototype.delete = function(callback, failedCallback) { var paramClient = new Service({ ros : this.ros, name : '/rosapi/delete_param', @@ -80,7 +86,7 @@ Param.prototype.delete = function(callback) { name : this.name }); - paramClient.callService(request, callback); + paramClient.callService(request, callback, failedCallback); }; module.exports = Param;