How to use the io-functions-commons/dist/src/utils/errors.PermanentError function in io-functions-commons

To help you get started, we’ve selected a few io-functions-commons 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 teamdigitale / io-functions / lib / webhook_queue_handler.ts View on Github external
response => {
        if (response.error) {
          return left(
            // in case of server HTTP 5xx errors we trigger a retry
            response.serverError
              ? TransientError(
                  `Transient HTTP error calling API Proxy: ${response.text}`
                )
              : PermanentError(
                  `Permanent HTTP error calling API Proxy: ${response.text}`
                )
          );
        }
        return right(response);
      },
      err => {
github teamdigitale / io-functions / lib / emailnotifications_queue_handler.ts View on Github external
TransientError(
        `Notification not found|notification=${notificationId}|message=${
          message.id
        }`
      )
    );
  }

  const errorOrEmailNotification = EmailNotification.decode(
    maybeEmailNotification.value
  );

  if (isLeft(errorOrEmailNotification)) {
    const error = readableReport(errorOrEmailNotification.value);
    return left(
      PermanentError(
        `Wrong format for email notification|notification=${notificationId}|message=${
          message.id
        }|${error}`
      )
    );
  }

  const emailNotification = errorOrEmailNotification.value.channels.EMAIL;

  const documentHtml = await generateDocumentHtml(
    content.subject,
    content.markdown,
    senderMetadata
  );

  // converts the HTML to pure text to generate the text version of the message
github teamdigitale / io-functions / lib / webhook_queue_handler.ts View on Github external
TransientError(
        `Notification not found|notification=${notificationId}|message=${
          message.id
        }`
      )
    );
  }

  const errorOrWebhookNotification = WebhookNotification.decode(
    maybeWebhookNotification.value
  );

  if (isLeft(errorOrWebhookNotification)) {
    const error = readableReport(errorOrWebhookNotification.value);
    return left(
      PermanentError(
        `Wrong format for webhook notification|notification=${notificationId}|message=${
          message.id
        }|${error}`
      )
    );
  }

  const webhookNotification = errorOrWebhookNotification.value.channels.WEBHOOK;

  const startWebhookCallTime = process.hrtime();

  const sendResult = await sendToWebhook(
    webhookNotification.url,
    message,
    content,
    senderMetadata

io-functions-commons

Common code for Azure functions

MIT
Latest version published 4 years ago

Package Health Score

50 / 100
Full package analysis

Similar packages