blish-hud / KillProof-Module

MIT License
3 stars 3 forks source link

Unhandled exception when API returns a non-JSON response #1

Closed BlishHUD closed 4 years ago

BlishHUD commented 4 years ago

Ni at 11/17/2019 4:03:34 PM +00:00

Bug Report: Module: Killproof.me Issue: Module crashes on invalid API response Related code: https://github.com/TybaIt/Community-Module-Pack/blob/60e7578cbb725dea21c00adc5c4219f44f85fcbe/Kill%20Proof%20Module/KillProofModule.cs#L132 Exception: ```Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. at Newtonsoft.Json.JsonTextReader.ParseValue() at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Kill_Proof_Module.KillProofModule.d__40.MoveNext() in F:\Git\Community-Module-Pack\Kill Proof Module\KillProofModule.cs:line 123


The API (reverse proxy?) server likes to respond with html if the API backend doesn't respond in time

REF: https://discordapp.com/channels/531175899588984842/534492173362528287/645655282294325248

dlamkins commented 4 years ago

Fixed in https://github.com/blish-hud/KillProof-Module/commit/5abb333150644c4a637a7f96edc6fb4419b9215c.