UNPKG

@api-buddy/sendgrid

Version:

API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails

63 lines (62 loc) 1.81 kB
import { SendGridError } from '../types'; /** * Custom error class for SendGrid API errors */ export declare class SendGridApiError extends Error { code: number; status: number; headers: Record<string, string>; body: any; errors: Array<{ message: string; field?: string; help?: string; }>; constructor(error: SendGridError); /** * Check if the error is a rate limit error */ get isRateLimit(): boolean; /** * Check if the error is an authentication error */ get isAuthError(): boolean; /** * Check if the error is a validation error */ get isValidationError(): boolean; /** * Get the first error message */ get firstErrorMessage(): string; } /** * Handle SendGrid API errors * @param error The error to handle * @returns A SendGridApiError instance */ export declare function handleSendGridError(error: unknown): SendGridApiError; /** * Check if an error is a SendGrid API error * @param error The error to check * @returns True if the error is a SendGrid API error */ export declare function isSendGridError(error: unknown): error is SendGridApiError; /** * Check if an error is a rate limit error * @param error The error to check * @returns True if the error is a rate limit error */ export declare function isRateLimitError(error: unknown): boolean; /** * Check if an error is an authentication error * @param error The error to check * @returns True if the error is an authentication error */ export declare function isAuthError(error: unknown): boolean; /** * Check if an error is a validation error * @param error The error to check * @returns True if the error is a validation error */ export declare function isValidationError(error: unknown): boolean;