ReadyRemit Error
Error response structure for SDK operations
Overview
The ReadyRemitError interface defines the structure for error responses that can occur during SDK operations. This interface should be returned by your callbacks (fetchAccessTokenDetails or verifyFundsAndCreateTransfer) when an error occurs instead of a successful response.
Definition
export interface ReadyRemitError {
code: string;
message: string;
}Properties
| Property | Type | Required | Description |
|---|---|---|---|
| code | string | Yes | A unique error code that identifies the type of error. Use consistent codes for easier debugging and error handling. |
| message | string | Yes | A human-readable description of the error that occurred. This message may be displayed to the user or logged for debugging. |
Common Error Codes
| Code | Description |
|---|---|
AUTH_ERROR | Authentication failed or token could not be retrieved |
NETWORK_ERROR | Network request failed |
INVALID_RESPONSE | Server returned an unexpected response format |
INSUFFICIENT_FUNDS | User does not have sufficient funds for the transfer |
TRANSFER_FAILED | Transfer could not be processed |
VALIDATION_ERROR | Request validation failed |
SERVER_ERROR | Internal server error occurred |
Sample Usage
Authentication Error
import type {
ReadyRemitTokenResponse,
ReadyRemitError
} from 'react-native-ready-remit-sdk';
const fetchAccessTokenDetails = async (): Promise<ReadyRemitTokenResponse | ReadyRemitError> => {
try {
const response = await fetch('https://your-api.com/oauth/token', {
method: 'POST',
});
if (!response.ok) {
return {
code: 'AUTH_ERROR',
message: `Authentication failed with status ${response.status}`,
};
}
const data = await response.json();
return {
accessToken: data.access_token,
expiresIn: data.expires_in,
scope: data.scope,
tokenType: data.token_type,
};
} catch (error) {
return {
code: 'NETWORK_ERROR',
message: error instanceof Error ? error.message : 'Network request failed',
};
}
};Transfer Error
import type {
ReadyRemitTransferRequest,
ReadyRemitTransferResponse,
ReadyRemitError
} from 'react-native-ready-remit-sdk';
const verifyFundsAndCreateTransfer = async (
request: ReadyRemitTransferRequest
): Promise<ReadyRemitTransferResponse | ReadyRemitError> => {
try {
const response = await fetch('https://your-api.com/transfers', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(request),
});
if (!response.ok) {
const errorData = await response.json();
return {
code: errorData.code || 'TRANSFER_FAILED',
message: errorData.message || 'Transfer could not be processed',
};
}
const data = await response.json();
return { transferId: data.id };
} catch (error) {
return {
code: 'NETWORK_ERROR',
message: error instanceof Error ? error.message : 'Network request failed',
};
}
};Example Error Response
{
"code": "INSUFFICIENT_FUNDS",
"message": "The source account does not have sufficient funds for this transfer"
}Related
- ReadyRemitTokenResponse - Success response for authentication
- ReadyRemitTransferResponse - Success response for transfers
- Fetch Access Token Details - Authentication callback
- Verify Funds and Create Transfer - Transfer callback
Updated 4 days ago
