From a92d99d6c05d6f735fec97d1cf4657815359d7d3 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 29 Dec 2021 14:15:33 +0100 Subject: [PATCH] feat: extended error logging (#49) * ios: add all possible error codes * android: add all possible error codes --- .../googleads/ReactNativeGoogleAdsCommon.java | 18 ++++++++++ ios/RNGoogleAds/RNGoogleAdsCommon.m | 34 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/android/src/main/java/io/invertase/googleads/ReactNativeGoogleAdsCommon.java b/android/src/main/java/io/invertase/googleads/ReactNativeGoogleAdsCommon.java index 5c34c559..efb7f891 100644 --- a/android/src/main/java/io/invertase/googleads/ReactNativeGoogleAdsCommon.java +++ b/android/src/main/java/io/invertase/googleads/ReactNativeGoogleAdsCommon.java @@ -221,16 +221,28 @@ public static String[] getCodeAndMessageFromAdErrorCode(int errorCode) { String message = "An unknown error occurred."; switch (errorCode) { + case AdRequest.ERROR_CODE_APP_ID_MISSING: + code = "app-id-missing"; + message = "The ad request was not made due to a missing app ID."; + break; case AdRequest.ERROR_CODE_INTERNAL_ERROR: code = "internal-error"; message = "Something happened internally; for instance, an invalid response was received from the" + " ad server."; break; + case AdRequest.ERROR_CODE_INVALID_AD_STRING: + code = "invalid-ad-string"; + message = "The ad string is invalid."; + break; case AdRequest.ERROR_CODE_INVALID_REQUEST: code = "invalid-request"; message = "The ad request was invalid; for instance, the ad unit ID was incorrect."; break; + case AdRequest.ERROR_CODE_MEDIATION_NO_FILL: + code = "mediation-no-fill"; + message = "The mediation adapter did not fill the ad request."; + break; case AdRequest.ERROR_CODE_NETWORK_ERROR: code = "network-error"; message = "The ad request was unsuccessful due to network connectivity."; @@ -240,6 +252,12 @@ public static String[] getCodeAndMessageFromAdErrorCode(int errorCode) { message = "The ad request was successful, but no ad was returned due to lack of ad inventory."; break; + case AdRequest.ERROR_CODE_REQUEST_ID_MISMATCH: + code = "request-id-mismatch"; + message = + "The AdInfo object inside the ad request has mismatching request IDs or the request ID" + + " in the ad string is not found."; + break; } String[] codeAndMessage = new String[2]; diff --git a/ios/RNGoogleAds/RNGoogleAdsCommon.m b/ios/RNGoogleAds/RNGoogleAdsCommon.m index bbd4f09e..0fa0e89d 100644 --- a/ios/RNGoogleAds/RNGoogleAdsCommon.m +++ b/ios/RNGoogleAds/RNGoogleAdsCommon.m @@ -98,10 +98,44 @@ + (NSDictionary *)getCodeAndMessageFromAdError:(NSError *)error { } else if (error.code == GADErrorNetworkError) { code = @"network-error"; message = @"The ad request was unsuccessful due to network connectivity."; + } else if (error.code == GADErrorServerError) { + code = @"server-error"; + message = @"The ad server experienced a failure processing the request."; + } else if (error.code == GADErrorOSVersionTooLow) { + code = @"os-version-too-low"; + message = @"The current device’s OS is below the minimum required version."; + } else if (error.code == GADErrorTimeout) { + code = @"timeout"; + message = @"The request was unable to be loaded before being timed out."; + } else if (error.code == GADErrorMediationDataError) { + code = @"mediation-data-error"; + message = @"The mediation response was invalid."; + } else if (error.code == GADErrorMediationAdapterError) { + code = @"mediation-adapter-error"; + message = @"Error finding or creating a mediation ad network adapter."; + } else if (error.code == GADErrorMediationInvalidAdSize) { + code = @"mediation-invalid-ad-size"; + message = @"Attempting to pass an invalid ad size to an adapter."; } else if (error.code == GADErrorInternalError) { code = @"internal-error"; message = @"Something happened internally; for instance, an invalid response was received from " @"the ad server."; + } else if (error.code == GADErrorInvalidArgument) { + code = @"invalid-argument"; + message = @"Invalid argument error."; + } else if (error.code == GADErrorReceivedInvalidResponse) { + code = @"received-invalid-response"; + message = @"Received invalid response."; + } else if (error.code == GADErrorMediationNoFill) { + code = @"mediation-no-fill"; + message = @"A mediation ad network adapter received an ad request, but did not fill. The " + @"adapter’s error is included as an underlyingError."; + } else if (error.code == GADErrorAdAlreadyUsed) { + code = @"ad-already-used"; + message = @"Will not send request because the ad object has already been used."; + } else if (error.code == GADErrorApplicationIdentifierMissing) { + code = @"application-identifier-missing"; + message = @"Will not send request because the application identifier is missing."; } return @{