in device/core/src/internal_client.ts [390:414]
private _validateDeviceMethodInputs(methodName: string, callback: (request: DeviceMethodRequest, response: DeviceMethodResponse) => void): void {
// Codes_SRS_NODE_INTERNAL_CLIENT_13_020: [ onDeviceMethod shall throw a ReferenceError if methodName is falsy. ]
if (!methodName) {
throw new ReferenceError('methodName cannot be \'' + methodName + '\'');
}
// Codes_SRS_NODE_INTERNAL_CLIENT_13_024: [ onDeviceMethod shall throw a TypeError if methodName is not a string. ]
if (typeof (methodName) !== 'string') {
throw new TypeError('methodName\'s type is \'' + typeof (methodName) + '\'. A string was expected.');
}
// Codes_SRS_NODE_INTERNAL_CLIENT_13_022: [ onDeviceMethod shall throw a ReferenceError if callback is falsy. ]
if (!callback) {
throw new ReferenceError('callback cannot be \'' + callback + '\'');
}
// Codes_SRS_NODE_INTERNAL_CLIENT_13_025: [ onDeviceMethod shall throw a TypeError if callback is not a Function. ]
if (typeof (callback) !== 'function') {
throw new TypeError('callback\'s type is \'' + typeof (callback) + '\'. A function reference was expected.');
}
// Codes_SRS_NODE_INTERNAL_CLIENT_13_023: [ onDeviceMethod shall throw an Error if a listener is already subscribed for a given method call. ]
if (this._methodCallbackMap[methodName]) {
throw new Error('A handler for this method has already been registered with the client.');
}
}