openapi-connected-service icon indicating copy to clipboard operation
openapi-connected-service copied to clipboard

Question: SwaggerException with TResult

Open mdmota opened this issue 6 years ago • 2 comments

How do I get the return object from throw new SwaggerException (...) using TResult? I need the deserialized object in return

mdmota avatar May 03 '19 16:05 mdmota

My error and success return objects are of the same type

mdmota avatar May 03 '19 16:05 mdmota

For example, in this way?

try
{ 

}
catch (SwaggerException ex)
{
    //if (ex.StatusCode != 200) // you can check statusCode
    return JsonConvert.DeserializeObject<TResult>(ex.Response, new JsonSerializerSettings());
}

or

try
{ 

}
catch (SwaggerException<TResult> ex)
{
    //if (ex.StatusCode != 200) // you can check statusCode
    return ex.Result;
}

unchase avatar May 04 '19 20:05 unchase