diff --git a/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/Network/NimbusClient.cs b/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/Network/NimbusClient.cs index 2149f29d..cefe71bf 100644 --- a/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/Network/NimbusClient.cs +++ b/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/Network/NimbusClient.cs @@ -62,8 +62,28 @@ public async Task MakeRequestAsync(BidRequest bidRequest) { return "{\"message\": \"Application Closed\"}"; } var nimbusResponse = await serverResponse.Content.ReadAsStringAsync(); -#endif - + if (nimbusResponse.IsNullOrEmpty()) + { + switch ((int)serverResponse.StatusCode) + { + case 400: + nimbusResponse = "{\"status_code\": 400, \"message\": \"POST data was malformed\"}"; + break; + case 404: + nimbusResponse = "{\"status_code\": 404,\"message\": \"No bids returned\"}"; + break; + case 429: + nimbusResponse = "{\"status_code\": 429,\"message\": \"Rate limited\"}"; + break; + case 500: + nimbusResponse = "{\"status_code\": 500,\"message\": \"Server is unavailable\"}"; + break; + default: + nimbusResponse = $"{{\"status_code\": {(int)serverResponse.StatusCode},\"message\": \"Unknown network error occurred\"}}"; + break; + } + } + #endif return nimbusResponse; }); } diff --git a/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/NimbusAdUnit.cs b/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/NimbusAdUnit.cs index d88de2fc..17530b0f 100644 --- a/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/NimbusAdUnit.cs +++ b/com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/NimbusAdUnit.cs @@ -117,17 +117,8 @@ await Task.Run(async () => { try { response = await jsonBody; } catch (Exception e) { } - - if (String.IsNullOrEmpty(response)) { - var networkError = new ErrResponse(); - networkError.Id = ""; - networkError.StatusCode = 0; - networkError.Message = "Unknown network error occurred"; - ErrResponse = networkError; - _adEvents.FireOnAdErrorEvent(this); - return; - } if (response.Contains("message")) { + Debug.unityLogger.Log("Nimbus",$"RESPONSE ERROR: {response}"); ErrResponse = JsonConvert.DeserializeObject(response); _adEvents.FireOnAdErrorEvent(this); return;