PaystackError.fromApiResponse constructor

PaystackError.fromApiResponse(
  1. Map<String, dynamic> response
)

Factory method to create error from API response.

Creates a PaystackError instance from raw Paystack API error response data. This method extracts error message, code, and details from the API response.

Parameters

  • response: Raw error response map from Paystack API

Returns

A new PaystackError instance with parsed error data.

Implementation

factory PaystackError.fromApiResponse(Map<String, dynamic> response) {
  return PaystackError(
    message: response['message'] as String? ?? 'Unknown error',
    code: response['code'] as String?,
    details: response,
  );
}