Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try-Catch Blocks (and exception handling in general) #11

Open
Thanakrit-Anutrakulchai opened this issue Nov 4, 2019 · 0 comments
Open

Comments

@Thanakrit-Anutrakulchai
Copy link

There doesn't seem to be any mention of exception handling, or how to format Try-catch blocks, on the style guide at all.

What's the opinion on this? If we're using them, then we should probably have an example somewhere, similar to how we have examples for 'for, if, switch' etc. And if it's discouraged, it should probably be stated.

Extra info about linter & try-catch
By default, the linter doesn't error on this format:

try 
{
  // code here
}
catch(Error& error) // note that there is no space before the bracket
{
  // code here
}

(Technically, it doesn't even assume try-catch blocks in the code. According to the Google style guide, Google C++ programmers "do not use c++ exceptions!")

Although, a one-line modification to the linter will also allow these two more common formats:

try {
  // code
}
catch (Error& err) {
  // code
}


try {
  // code
} catch (Error& err) {
  // code
}

Also: I skimmed the codebase with Ctrl+F (cmd+F) and found only 3 try-catch blocks in last year's repo so far, all in src/telemetry (/sendloop.cpp, /recvloop.cpp, /main.cpp) all using the last style shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant