1 .. title:: clang-tidy - google-objc-avoid-throwing-exception
3 google-objc-avoid-throwing-exception
4 ====================================
6 Finds uses of throwing exceptions usages in Objective-C files.
8 For the same reason as the Google C++ style guide, we prefer not throwing
9 exceptions from Objective-C code.
11 The corresponding C++ style guide rule:
12 https://google.github.io/styleguide/cppguide.html#Exceptions
14 Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
22 @throw [NSException exceptionWithName:...];
26 Instead, returning an error via ``NSError **`` is preferred:
30 - (BOOL)readFileWithError:(NSError **)error {
32 *error = [NSError errorWithDomain:...];
38 The corresponding style guide rule:
39 https://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions