== Why is this an issue?

Using checked exceptions forces method callers to deal with errors, either by propagating them or by handling them. Throwing exceptions makes them fully part of the API of the method.


But to keep the complexity for callers reasonable, methods should not throw more than one kind of checked exception.


=== Noncompliant code example

[source,java]
----
public void delete() throws IOException, SQLException {      // Noncompliant
  /* ... */
}
----


=== Compliant solution

[source,java]
----
public void delete() throws SomeApplicationLevelException {
  /* ... */
}
----


=== Exceptions

Overriding methods are not checked by this rule and are allowed to throw several checked exceptions.


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Refactor this method to throw at most one checked exception instead of: {Ex1, Ex2, Ex3, etc.}


'''
== Comments And Links
(visible only on this page)

=== on 29 Jul 2013, 15:20:34 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-248

=== on 29 Jul 2013, 23:48:51 Ann Campbell wrote:
There's no compliant example

=== on 31 Jul 2013, 16:24:16 Dinesh Bolkensteyn wrote:
'quickly' is a magic filler word ;-)

=== on 31 Jul 2013, 17:10:16 Dinesh Bolkensteyn wrote:
\[~freddy.mallet]


It seems that the checkstyle rule verifies the number of throws *statements*?


Are you sure this is a replacement?

=== on 21 Aug 2015, 15:17:03 Ann Campbell wrote:
FYI [~tamas.vajk] I've set C# to targeted on this rule

endif::env-github,rspecator-view[]
