NSwag: Missing brackets in else statment (C#)

My generated code includes…

                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
                            throw new SwaggerException("Service Unavailable - The caller has hit a throttle or the request was rejected because the Atom is starting or stopping.", (int)response_.StatusCode, responseData_, headers_, null);
                        }
                        else
                        if (status_ == "522")
                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
                            throw new SwaggerException("Connection Timed Out - This message is returned to the client when the SOA Worker Maximum Execution Time has been exceeded.", (int)response_.StatusCode, responseData_, headers_, null);
                        }
                        else
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
                        throw new SwaggerException("Unidentified Exception", (int)response_.StatusCode, responseData_, headers_, null);

Note the last else statement doesn’t have brackets around it. This causes a compiler error since responseData isn’t in the same scope as the throw statement that uses it.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 24 (11 by maintainers)

Most upvoted comments

Confirmed the issue is fixed on my machine using the latest build. Thank you for the quick turn-around and for this project in general. I couldn’t do my job without this tooling.