View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="NestedTryDepth"/>
5     </module>
6   </module>
7   */
8   package com.puppycrawl.tools.checkstyle.checks.coding.nestedtrydepth;
9   
10  // xdoc section -- start
11  public class Example1 {
12    void testMethod() {
13      try {
14        try { // OK, current depth is 1, default max allowed depth is also 1
15        } catch (Exception e) {}
16      } catch (Exception e) {}
17  
18      try {
19        try {
20          try { // violation, current depth is 2, default max allowed depth is 1
21          } catch (Exception e) {}
22        } catch (Exception e) {}
23      } catch (Exception e) {}
24  
25      try {
26        try {
27          try { // violation, current depth is 2, default max allowed depth is 1
28            try { // violation, current depth is 3, default max allowed depth is 1
29              try { // violation, current depth is 4, default max allowed depth is 1
30              } catch (Exception e) {}
31            } catch (Exception e) {}
32          } catch (Exception e) {}
33        } catch (Exception e) {}
34      } catch (Exception e) {}
35    }
36  }
37   // xdoc section -- end