Skip to content

[BUG] [csharp] DefaultExceptionFactory hides exceptions #8732

Open
@chrbkr

Description

@chrbkr

The openapi-generator creates this ExceptionFactory:

/// <summary>
/// Default creation of exceptions for a given method name and response object
/// </summary>
public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) =>
{
var status = (int)response.StatusCode;
if (status >= 400)
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.Content),
response.Content);
}
return null;
};

First of all, I'm not sure handling response codes as exceptions is good practice, but that could be debated.

However, what's much worse is that real exceptions are hidden - in case a timeout occurs, or the connection is closed etc., all I get is a null response instead of the real exception.

Am I missing something? How are other people handling this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions