Skip to content

Commit

Permalink
feat: extended error logging (#49)
Browse files Browse the repository at this point in the history
* ios: add all possible error codes
* android: add all possible error codes
  • Loading branch information
dylancom authored Dec 29, 2021
1 parent 63aa1ff commit a92d99d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand All @@ -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];
Expand Down
34 changes: 34 additions & 0 deletions ios/RNGoogleAds/RNGoogleAdsCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 @{
Expand Down

0 comments on commit a92d99d

Please sign in to comment.