private ErrorDescription CheckForErrors(bool status, string message, Func <string, Error> checkError) { //status == false == network error if (!status) { return(new ErrorDescription(string.Empty, message, Error.NetworkError)); } //else try to deserialize mistake MessageJson messageJson = DeserializeError(message); //if request got an error if (messageJson != null && messageJson.error != null && !string.IsNullOrEmpty(messageJson.error.code)) { messageJson.error.error = checkError(messageJson.error.code); if (messageJson.error.error == Error.IdentifiedError) { messageJson.error.error = CheckGeneralErrors(messageJson.error.code); } return(messageJson.error); } //else if success return(null); }
private MessageJson DeserializeError(string recievedMessage) { MessageJson message = new MessageJson(); try { message = JsonUtility.FromJson <MessageJson>(recievedMessage); } catch (Exception) { } return(message); }