hokein added inline comments.
================ Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1 +//===--- AvoidThrowingObjcExceptionCheck.h - clang-tidy----------*- C++ -*-===// +// ---------------- benhamilton wrote: > Naming nit-pick: We are currently using `ObjC`, not `Objc`. We also need to rename the file name. ================ Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6-7 + +This check finds @throw usages in Objective-C files. According to Google's Objective-C +Guide, we should not use @throw to handle exceptions. + ---------------- benhamilton wrote: > How about: > > This check finds @throw usages in Objective-C files. [For the same reasons as > the Google C++ style > guide](https://google.github.io/styleguide/cppguide.html#Exceptions), we > [prefer not throwing exceptions from Objective-C > code](http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions). > > Instead, prefer passing in `NSError **` and return `BOOL` to indicate success > or failure. A counterexample: > > ```lang=objectivec > - (void)readFile { > if ([self isError]) { > @throw [NSException exceptionWithName:...]; > } > } > ``` > > Instead, returning an error via `NSError **` is preferred: > > ```lang=objectivec > - (BOOL)readFileWithError:(NSError **)error { > if ([self isError]) { > *error = [NSError errorWithDomain:...]; > return NO; > } > return YES; > } > ``` > +1 on an illustrated sample :) https://reviews.llvm.org/D40058 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits