From 07724ea60abcf6fb4919351d2826941a1890e541 Mon Sep 17 00:00:00 2001 From: Sebastian Villena <97059974+ruisebas@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:58:09 -0400 Subject: [PATCH] fix(PushNotifications): Fixing .network error not being correctly reported (#3314) --- ...imeError+PushNotificationsErrorConvertible.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Error/CommonRunTimeError+PushNotificationsErrorConvertible.swift b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Error/CommonRunTimeError+PushNotificationsErrorConvertible.swift index c74f540617..0c07856389 100644 --- a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Error/CommonRunTimeError+PushNotificationsErrorConvertible.swift +++ b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Error/CommonRunTimeError+PushNotificationsErrorConvertible.swift @@ -12,12 +12,17 @@ import AwsCommonRuntimeKit extension CommonRunTimeError: PushNotificationsErrorConvertible { var pushNotificationsError: PushNotificationsError { + if isConnectivityError { + return .network( + PushNotificationsPluginErrorConstants.deviceOffline.errorDescription, + PushNotificationsPluginErrorConstants.deviceOffline.recoverySuggestion, + self + ) + } + switch self { case .crtError(let crtError): - let errorDescription = isConnectivityError - ? AWSPinpointErrorConstants.deviceOffline.errorDescription - : crtError.message - return .unknown(errorDescription, self) + return .unknown(crtError.message, self) } } }