handleError static method
Handles different types of errors with appropriate messages
Implementation
static String handleError(dynamic error, [StackTrace? stackTrace]) {
if (error is http.ClientException) {
return 'Network error: ${error.message}';
} else if (error is TimeoutException) {
return 'Request timed out. Please check your internet connection and try again.';
} else if (error is FormatException) {
return 'Invalid response format from server. Please try again.';
} else if (error is String) {
return error;
} else {
developer.log('Unexpected error: $error\nStack trace: $stackTrace',
name: 'MonerisPayment', error: error);
return 'An unexpected error occurred. Please try again.';
}
}