How to use the azure-iot-common.errors.NotImplementedError function in azure-iot-common

To help you get started, we’ve selected a few azure-iot-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-iot-sdk-node / device / core / lib / twin.js View on Github external
/* Codes_SRS_NODE_DEVICE_TWIN_18_028: [** if `fromDeviceClient` has previously been called for this client, it shall perform a GET operation and return the same object **]** */
  if (client._twin) {
    client._twin._getPropertiesFromService(function (err) {
        done(err,client._twin);
      });
  } else {
    /* Codes_SRS_NODE_DEVICE_TWIN_18_029: [** if `fromDeviceClient` is called with 2 different `client`s, it shall return 2 unique `Twin` objects **]** */
    /* Codes_SRS_NODE_DEVICE_TWIN_18_003: [** `fromDeviceClient` shall allocate a new `Twin` object **]**  */
    var twin = new Twin(client);

    twin.on("newListener", twin._handleNewListener.bind(twin));

    /* Codes_SRS_NODE_DEVICE_TWIN_18_005: [** If the protocol does not contain a `getTwinReceiver` method, `fromDeviceClient` shall throw a `NotImplementedError` error **]**  */
    if (!client._transport.getTwinReceiver) {
      throw new errors.NotImplementedError('transport does not support Twin');
    } else {
      client._twin = twin;
      client.on('_connected', function() {
        twin._connectSubscribeAndGetProperties(function() {});
      });
      twin._connectSubscribeAndGetProperties(done);
    }
  }
};
github Azure / azure-iot-sdk-node / common / transport / mqtt / src / mqtt_translate_error.ts View on Github external
export function translateError(mqttError: Error): MqttTransportError {
  let err: MqttTransportError;

  if (mqttError.message) {
    /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_002: [** `translateError` shall return a `NotConnectedError` if the MQTT error message contains the string 'client disconnecting' **]** */
    if (mqttError.message.indexOf('client disconnecting') > -1) {
      err = new errors.NotConnectedError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('Invalid topic') > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_003: [** `translateError` shall return a `FormatError` if the MQTT error message contains the string 'Invalid topic' **]** */
      err = new errors.FormatError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('No connection to broker') > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_004: [** `translateError` shall return a `NotConnectedError` if the MQTT error message contains the string 'No connection to broker' **]** */
      err = new errors.NotConnectedError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('Unacceptable protocol version') > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_005: [** `translateError` shall return a `NotImplementedError` if the MQTT error message contains the string 'Unacceptable protocol version' **]** */
      err = new errors.NotImplementedError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('Identifier rejected') > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_006: [** `translateError` shall return a `UnauthorizedError` if the MQTT error message contains the string 'Identifier rejected' **]** */
      err = new errors.UnauthorizedError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('Server unavailable' ) > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_007: [** `translateError` shall return a `ServiceUnavailableError` if the MQTT error message contains the string 'Server unavailable' **]** */
      err = new errors.ServiceUnavailableError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('Bad username or password') > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_008: [** `translateError` shall return a `UnauthorizedError` if the MQTT error message contains the string 'Bad username or password' **]** */
      err = new errors.UnauthorizedError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('Not authorized') > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_009: [** `translateError` shall return a `UnauthorizedError` if the MQTT error message contains the string 'Not authorized' **]** */
      err = new errors.UnauthorizedError('mqtt.js returned ' + mqttError.message + ' error');
    } else if (mqttError.message.indexOf('unrecognized packet type') > -1) {
      /* Codes_SRS_NODE_DEVICE_MQTT_ERRORS_18_010: [** `translateError` shall return a `InternalServerError` if the MQTT error message contains the string 'unrecognized packet type' **]** */
      err = new errors.InternalServerError('mqtt.js returned ' + mqttError.message + ' error');
    } else {
github Azure / azure-iot-sdk-node / security / tpm / src / tpm.ts View on Github external
getEndorsementKey(callback: (err?: Error) => void): void {
    throw new errors.NotImplementedError();
  }
github Azure / azure-iot-sdk-node / device / transport / mqtt / src / mqtt.ts View on Github external
reject(): void {
    /*Codes_SRS_NODE_DEVICE_MQTT_16_006: [The ‘reject’ method shall throw because MQTT doesn’t support rejecting messages.] */
    throw new errors.NotImplementedError('the MQTT transport does not support rejecting messages.');
  }
github Azure / azure-iot-sdk-node / device / core / src / module_client.ts View on Github external
static fromConnectionString(connStr: string, transportCtor: any): ModuleClient {
    /*Codes_SRS_NODE_MODULE_CLIENT_05_003: [The fromConnectionString method shall throw ReferenceError if the connStr argument is falsy.]*/
    if (!connStr) throw new ReferenceError('connStr is \'' + connStr + '\'');

    const cn = ConnectionString.parse(connStr);

    /*Codes_SRS_NODE_MODULE_CLIENT_16_087: [The `fromConnectionString` method shall create a new `SharedAccessKeyAuthorizationProvider` object with the connection string passed as argument if it contains a SharedAccessKey parameter and pass this object to the transport constructor.]*/
    let authenticationProvider: AuthenticationProvider;

    if (cn.SharedAccessKey) {
      authenticationProvider = SharedAccessKeyAuthenticationProvider.fromConnectionString(connStr);
    } else {
      /*Codes_SRS_NODE_MODULE_CLIENT_16_001: [The `fromConnectionString` method shall throw a `NotImplementedError` if the connection string does not contain a `SharedAccessKey` field because x509 authentication is not supported yet for modules.]*/
      throw new errors.NotImplementedError('ModuleClient only supports SAS Token authentication');
    }

    /*Codes_SRS_NODE_MODULE_CLIENT_05_006: [The fromConnectionString method shall return a new instance of the Client object, as by a call to new Client(new transportCtor(...)).]*/
    return new ModuleClient(new transportCtor(authenticationProvider), null);
  }
github Azure / azure-iot-sdk-node / security / tpm / src / tpm.ts View on Github external
activateSymmetricIdentity(callback: (err?: Error) => void): void {
    throw new errors.NotImplementedError();
  }
}
github Azure / azure-iot-sdk-node / device / transport / mqtt / src / mqtt.ts View on Github external
abandon(): void {
    /*Codes_SRS_NODE_DEVICE_MQTT_16_004: [The ‘abandon’ method shall throw because MQTT doesn’t support abandoning messages.] */
    throw new errors.NotImplementedError('The MQTT transport does not support abandoning messages.');
  }
github Azure / azure-iot-sdk-node / device / transport / amqp / src / amqp.ts View on Github external
sendEventBatch(messages: Message[], done: (err?: Error, result?: results.MessageEnqueued) => void): void {
    /*Codes_SRS_NODE_DEVICE_AMQP_16_052: [The `sendEventBatch` method shall throw a `NotImplementedError`.]*/
    throw new errors.NotImplementedError('AMQP Transport does not support batching yet');
  }
github Azure / azure-iot-sdk-node / security / tpm / src / tpm.ts View on Github external
getStorageRootKey(callback: (err?: Error) => void): void {
    throw new errors.NotImplementedError();
  }
github Azure / azure-iot-sdk-node / security / tpm / src / tpm.ts View on Github external
signWithIdentity(callback: (err?: Error) => void): void {
    throw new errors.NotImplementedError();
  }