How to use the azure-iot-amqp-base.translateError function in azure-iot-amqp-base

To help you get started, we’ve selected a few azure-iot-amqp-base 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 / transport / amqp / src / amqp.ts View on Github external
const getTranslatedError = function(err?: Error, message?: string): Error {
  if (err instanceof errors.UnauthorizedError || err instanceof errors.NotConnectedError || err instanceof errors.DeviceNotFoundError) {
    return err;
  }
  return translateError(message, err);
};
github Azure / azure-iot-sdk-node / device / transport / amqp / src / amqp.ts View on Github external
return function (err?: Error, result?: any): void {
    if (err) {
      done(translateError(errorMessage, err));
    } else {
      done(null, result);
    }
  };
};
github Azure / azure-iot-sdk-node / provisioning / transport / amqp / src / amqp.ts View on Github external
this._senderLink.send(requestMessage, (err) => {
              if (err) {
                delete this._operations[requestMessage.correlation_id];
                const translatedError = translateError('registration failure', err);
                /*Codes_SRS_NODE_PROVISIONING_AMQP_06_007: [If the `registrationRequest` send request is rejected with an `InternalError` or `ThrottlingError`, the result.status value will be set with `registering` and the callback will be invoked with *no* error object.] */
                if ((translatedError instanceof errors.InternalServerError) || ((translatedError as AmqpTransportError) instanceof errors.ThrottlingError)) {
                  debug('retryable error on registration: ' + err.name);
                  let retryAfterInMilliseconds: number;
                  /*Codes_SRS_NODE_PROVISIONING_AMQP_06_009: [If the `registrationRequest` rejection error contains the info property`retry-after`, it will be interpreted as the number of seconds that should elapse before the next attempted operation.  Otherwise default.] */
                  if ((err as any).info && (err as any).info[MessagePropertyNames.retryAfter]) {
                    retryAfterInMilliseconds = Number(((err as any).info[MessagePropertyNames.retryAfter] as string)) * 1000;
                  } else {
                    retryAfterInMilliseconds = this._config.pollingInterval;
                  }
                  callback(null, {status: 'registering'}, null, retryAfterInMilliseconds);
                } else {
                  debug('non-retryable error on registration: ' + err.name);
                  /*Codes_SRS_NODE_PROVISIONING_AMQP_16_011: [The `registrationRequest` method shall call its callback with an error if the transport fails to send the request message.]*/
                  callback(err);
                }
github Azure / azure-iot-sdk-node / device / transport / amqp / src / amqp.ts View on Github external
this._deviceMethodClient.detach((detachErr) => {
                    if (detachErr) {
                      debug('error detaching methods links: ' + detachErr.toString());
                      if (!finalError) {
                        finalError = translateError('error while detaching the methods links when disconnecting', detachErr);
                      }
                    } else {
                      debug('device methods links detached.');
                    }
                    callback();
                  });
                }
github Azure / azure-iot-sdk-node / device / transport / amqp / src / amqp.ts View on Github external
this._stopC2DListener(err, (detachErr) => {
                    if (!finalError && detachErr) {
                      finalError = translateError('error while detaching the D2C link when disconnecting', detachErr);
                    }
                    callback();
                  });
                } else {
github Azure / azure-iot-sdk-node / device / transport / amqp / src / amqp.ts View on Github external
this._amqp.connect(uri, this._config.x509, (err, connectResult) => {
              if (err) {
                this._fsm.transition('disconnected', connectCallback, translateError('AMQP Transport: Could not connect', err));
              } else {
                this._fsm.transition('authenticating', connectCallback, connectResult);
              }
            });
          },

azure-iot-amqp-base

AMQP operations used by Azure IoT device and service SDKs

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages