Perhaps a silly question, but what is the criteria...
# detekt
r
Perhaps a silly question, but what is the criteria for
TooGenericExceptionCaught
? It's flagging this as being too generic, but
IndexOutOfBoundsException
seems pretty appropriate. https://github.com/rgmz/NewPipe/blob/75917c7f61cde0537075b3e1c5442cdf27755026/app/src/main/java/org/schabi/newpipe/info_list/StreamSegmentAdapter.kt#L54
s
The rule
TooGenericExceptionCaught
reports all exceptions of the following types being caught in a
catch
clause.
['ArrayIndexOutOfBoundsException', 'Error', 'Exception', 'IllegalMonitorStateException', 'IndexOutOfBoundsException', 'NullPointerException', 'RuntimeException', 'Throwable']
Perhaps, you could check whether the index is within the collection bounds, so you don't need to catch the
IndexOutOfBoundsException
.
r
Gotcha. Can't believe I missed the documentation; I was searching primarily GitHub issues under the assumption that it was a bug.
459 Views