You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On some occasion during MangoPay failures, we receive what we suppose is a HTTP 500 error (not sure because the mapping of the error code happens after the ArgumentNullException).
In your SDK, you try to deserialize the content of the response as a ErrorResponse, but it fails because the content is null.
I won't make a PR because their is no guideline, but here is the modified code :
using System;namespace MangoPay.SDK.Core
{/// <summary>Response exception class.</summary>publicclassResponseException:ApplicationException{/// <summary>Instantiates new ResponseException object.</summary>publicResponseException(){}/// <summary>Instantiates new ResponseException object.</summary>/// <param name="message">JSON data that came as a response from API.</param>/// <param name="responseStatusCode">Response status code from API.</param>publicResponseException(stringmessage,intresponseStatusCode):base(message){this.ResponseErrorRaw =message;this.ResponseStatusCode =responseStatusCode;this.ResponseError = ResponseError.FromJSON(message);}/// <summary>Raw text data that came as response from API.</summary>publicstringResponseErrorRaw;/// <summary>Deserialized response error data.</summary>publicResponseErrorResponseError=new ResponseError();/// <summary>Response status code from API.</summary>publicintResponseStatusCode;}}
using Newtonsoft.Json;using System.Collections.Generic;namespace MangoPay.SDK.Core
{/// <summary>Response error class, used as part of ResponseException object. /// You don't need to instantiate it by yourself - SDK will take care of this for you.</summary>publicsealedclassResponseError{internalResponseError(){}/// <summary>General error text message.</summary>publicstringMessage;/// <summary>Type of error.</summary>publicstringType;/// <summary>Error identifier.</summary>publicstringId;/// <summary>Date (UNIX timestamp).</summary>publiclongDate;/// <summary>Collection of field name / error description pairs.</summary>publicDictionary<string,string>errors;/// <summary>Deserializes JSON ResponseError instance.</summary>/// <param name="serializedResponseError">JSON-serialized ResponseError instance.</param>/// <returns>Returns new instance of ResponseError class or null if deserialization failed.</returns>publicstatic ResponseError FromJSON(stringserializedResponseError){if(string.IsNullOrEmpty(serializedResponseError)){returnnull;}try{return JsonConvert.DeserializeObject<ResponseError>(serializedResponseError);}catch(JsonException){returnnull;}}}}
The important part is to check for null (and maybe empty) string before trying to deserialize the ErrorResponse.
The text was updated successfully, but these errors were encountered:
On some occasion during MangoPay failures, we receive what we suppose is a HTTP 500 error (not sure because the mapping of the error code happens after the ArgumentNullException).
In your SDK, you try to deserialize the content of the response as a ErrorResponse, but it fails because the content is null.
I won't make a PR because their is no guideline, but here is the modified code :
The important part is to check for null (and maybe empty) string before trying to deserialize the ErrorResponse.
The text was updated successfully, but these errors were encountered: