Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

455 B
Raw Blame
/** Record that an error escaped an engine send, independently of its HTTP status. */
const attemptedSendFailures = new WeakSet<object>();

export function markEngineSendFailure<T>(error: T): T {
  if (error !== null && typeof error === 'object') attemptedSendFailures.add(error);
  return error;
}

export function isEngineSendFailure(error: unknown): boolean {
  return error !== null && typeof error === 'object' && attemptedSendFailures.has(error);
}