Missing brackets in else statment (C#)
See original GitHub issueMy 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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:24 (11 by maintainers)
Top Results From Across the Web
Is it a bad practice to use an if-statement without curly ...
Use braces for all if statements even the simple ones. Or, rewrite a simple if statement to use the ternary operator:
Read more >coding style - Single statement if block - braces or no?
A single-statement block which is delimited by braces wastes one to two lines. ... Not so good, especially in C/C++-like languages:
Read more >26/30, no curly brackets after "if" and "else"
Yes it is not necessary to use curly braces after conditions and loops (functions always need them) IF and only if there is...
Read more >If blocks without curly braces ಠ_ಠ
The only situation where braces can be safely left out is when the single statement is on the same line as the "if"....
Read more >Can I use nested statements without curly brackets?
If you are talking about C/C++ then you can use nested statements without curly brackets but it allows till only 1 line. Example:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
ok. again
在 2018年8月10日 上午09:22,Rico Suter notifications@github.com 寫道:
It was truncated
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.