mapNativeError function
Implementation
PlatformException mapNativeError(dynamic error) {
if (error is PlatformException) {
return PlatformException(
code: error.code,
message: _enhanceErrorMessage(error.code, error.message ?? ''),
details: error.details,
stacktrace: error.stacktrace,
);
}
if (error is MissingPluginException) {
return PlatformException(
code: DitoError.initializationFailed,
message:
'Missing plugin implementation. Rebuild the app so native changes are compiled (flutter clean, flutter pub get, reinstall).',
);
}
if (error is Exception) {
return PlatformException(
code: DitoError.networkError,
message: 'Network error occurred: ${error.toString()}. Please check your internet connection and try again.',
);
}
return PlatformException(
code: DitoError.networkError,
message: 'An unexpected error occurred: $error. Please try again or contact support if the problem persists.',
);
}