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