PaymentException class

Base class for all payment-related exceptions in the CoFee Payment SDK.

This class provides a structured way to handle various types of errors that can occur during the payment process. It includes detailed information about the error, such as the error message, HTTP status code, error type, and the original response.

Example:

throw PaymentException(
  'Failed to process payment',
  statusCode: 500,
  errorCode: 'SERVER_ERROR',
  errorType: PaymentErrorType.api,
);
Implemented types
Implementers

Constructors

PaymentException.new(String message, {dynamic cause, int? statusCode, String? responseBody, PaymentErrorType errorType = PaymentErrorType.unknown, String? errorCode})
Creates a new PaymentException with the specified details.

Properties

cause → dynamic
The original error that caused this exception, if any. Useful for debugging and error tracking.
final
errorCode String?
Error code from the API response, if available. This is the specific error code returned by the server. Example: 'ERR_PAYMENT_ORDER_NOT_FOUND'
final
errorType PaymentErrorType
The type of payment error that occurred. This helps categorize the error for appropriate handling.
final
hashCode int
The hash code for this object.
no setterinherited
message String
A human-readable error message describing what went wrong. This should be clear and actionable for developers.
final
responseBody String?
Raw response body from the API if available. This contains the complete server response for debugging.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int?
HTTP status code if the error is related to an API call. This will be null for non-HTTP related errors.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited