/**
 * Rejection type shared by the Africa's Talking callback mapper and the inbound media guard.
 *
 * Lives in its own module so the mapper and the media guard can both raise it without importing
 * each other.
 */

export type AfricasTalkingWebhookReason =
  | 'invalid_payload' | 'unknown_event' | 'ambiguous_payload'
  | 'channel_mismatch' | 'media_rejected' | 'media_unavailable' | 'media_busy';

/** Fixed messages only — safe to return to the caller and to log. */
export class AfricasTalkingWebhookError extends Error {
  constructor(
    readonly reason: AfricasTalkingWebhookReason,
    readonly statusCode: number,
    message: string,
  ) {
    super(message);
    this.name = 'AfricasTalkingWebhookError';
  }
}
