View Javadoc
1   /*
2   IllegalCatch
3   illegalClassNames = java.lang.Error, java.lang.Exception, NullPointerException, \
4                       OneMoreException, RuntimeException, SQLException
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.illegalcatch;
10  
11  public class InputIllegalCatchCheckMultipleExceptions {
12      public void foo() throws OneMoreException {
13          try {
14                  foo1();
15          } catch (RuntimeException | SQLException e) {}
16          // 2 violations above
17          // "Catching 'RuntimeException' is not allowed"
18          // "Catching 'SQLException' is not allowed"
19          try {
20                  foo1();
21          } catch (RuntimeException | SQLException | OneMoreException e) {}
22          // 3 violations above
23          // "Catching 'RuntimeException' is not allowed "
24          // "Catching 'SQLException' is not allowed"
25          // "Catching 'OneMoreException' is not allowed"
26          try {
27                  foo1();
28          } catch (OneMoreException | RuntimeException | SQLException e) {}
29          // 3 violations above
30          // "Catching 'OneMoreException' is not allowed"
31          // "Catching 'RuntimeException' is not allowed"
32          // "Catching 'SQLException' is not allowed"
33          try {
34                  foo1();
35          } catch (OneMoreException | SQLException | RuntimeException e) {}
36          // 3 violations above
37          // "Catching 'OneMoreException' is not allowed"
38          // "Catching 'SQLException' is not allowed"
39          // "Catching 'RuntimeException' is not allowed"
40  
41      }
42  
43      private void foo1() throws RuntimeException, SQLException, OneMoreException {
44  
45      }
46  
47      private class SQLException extends Exception {
48  
49      }
50  
51      private class OneMoreException extends Exception {
52  
53      }
54  }