How to use the rhea-promise.isAmqpError function in rhea-promise

To help you get started, we’ve selected a few rhea-promise 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-sdk-for-js / sdk / servicebus / service-bus / src / core / messageReceiver.ts View on Github external
new Date(Date.now()).toString(),
              new Date(totalAutoLockRenewDuration).toString(),
              bMessage.messageId
            );
            this._clearMessageLockRenewTimer(bMessage.messageId as string);
          }
        };
        // start
        autoRenewLockTask();
      }
      try {
        await this._onMessage(bMessage);
        this._clearMessageLockRenewTimer(bMessage.messageId as string);
      } catch (err) {
        // This ensures we call users' error handler when users' message handler throws.
        if (!isAmqpError(err)) {
          log.error(
            "[%s] An error occurred while running user's message handler for the message " +
              "with id '%s' on the receiver '%s': %O",
            connectionId,
            bMessage.messageId,
            this.name,
            err
          );
          this._onError!(err);
        }

        // Do not want renewLock to happen unnecessarily, while abandoning the message. Hence,
        // doing this here. Otherwise, this should be done in finally.
        this._clearMessageLockRenewTimer(bMessage.messageId as string);
        const error = translate(err);
        // Nothing much to do if user's message handler throws. Let us try abandoning the message.
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / session / messageSession.ts View on Github external
);
          return;
        }

        resetTimerOnNewMessageReceived();
        const bMessage: ServiceBusMessage = new ServiceBusMessage(
          this._context,
          context.message!,
          context.delivery!,
          true
        );
        try {
          await this._onMessage(bMessage);
        } catch (err) {
          // This ensures we call users' error handler when users' message handler throws.
          if (!isAmqpError(err)) {
            log.error(
              "[%s] An error occurred while running user's message handler for the message " +
                "with id '%s' on the receiver '%s': %O",
              connectionId,
              bMessage.messageId,
              this.name,
              err
            );
            this._onError!(err);
          }

          const error = translate(err);
          // Nothing much to do if user's message handler throws. Let us try abandoning the message.
          if (
            !bMessage.delivery.remote_settled &&
            this.receiveMode === ReceiveMode.peekLock &&
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / session / messageSession.ts View on Github external
);
          return;
        }

        resetTimerOnNewMessageReceived();
        const bMessage: ServiceBusMessage = new ServiceBusMessage(
          this._context,
          context.message!,
          context.delivery!,
          true
        );
        try {
          await this._onMessage(bMessage);
        } catch (err) {
          // This ensures we call users' error handler when users' message handler throws.
          if (!isAmqpError(err)) {
            log.error(
              "[%s] An error occurred while running user's message handler for the message " +
                "with id '%s' on the receiver '%s': %O",
              connectionId,
              bMessage.messageId,
              this.name,
              err
            );
            this._onError!(err);
          }

          const error = translate(err);
          // Nothing much to do if user's message handler throws. Let us try abandoning the message.
          if (
            !bMessage.delivery.remote_settled &&
            this.receiveMode === ReceiveMode.peekLock &&
github Azure / azure-sdk-for-js / sdk / core / core-amqp / src / errors.ts View on Github external
export function translate(err: AmqpError | Error): MessagingError {
  if ((err as MessagingError).translated) {
    // already translated
    return err as MessagingError;
  }

  let error: MessagingError = err as MessagingError;

  // Built-in errors like TypeError and RangeError should not be retryable as these indicate issues
  // with user input and not an issue with the Messaging process.
  if (err instanceof TypeError || err instanceof RangeError) {
    error.retryable = false;
    return error;
  }

  if (isAmqpError(err)) {
    // translate
    const condition = (err as AmqpError).condition;
    const description = (err as AmqpError).description as string;
    error = new MessagingError(description);
    if ((err as any).stack) error.stack = (err as any).stack;
    error.info = (err as AmqpError).info;
    error.condition = condition;
    if (condition) {
      error.name = ConditionErrorNameMapper[condition as keyof typeof ConditionErrorNameMapper];
    }
    if (!error.name) error.name = "MessagingError";
    if (
      description &&
      (description.includes("status-code: 404") ||
        description.match(/The messaging entity .* could not be found.*/i) !== null)
    ) {
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / core / messageReceiver.ts View on Github external
new Date(Date.now()).toString(),
              new Date(totalAutoLockRenewDuration).toString(),
              bMessage.messageId
            );
            this._clearMessageLockRenewTimer(bMessage.messageId as string);
          }
        };
        // start
        autoRenewLockTask();
      }
      try {
        await this._onMessage(bMessage);
        this._clearMessageLockRenewTimer(bMessage.messageId as string);
      } catch (err) {
        // This ensures we call users' error handler when users' message handler throws.
        if (!isAmqpError(err)) {
          log.error(
            "[%s] An error occurred while running user's message handler for the message " +
              "with id '%s' on the receiver '%s': %O",
            connectionId,
            bMessage.messageId,
            this.name,
            err
          );
          this._onError!(err);
        }

        // Do not want renewLock to happen unnecessarily, while abandoning the message. Hence,
        // doing this here. Otherwise, this should be done in finally.
        this._clearMessageLockRenewTimer(bMessage.messageId as string);
        const error = translate(err);
        // Nothing much to do if user's message handler throws. Let us try abandoning the message.