CatchParameterName
Since Checkstyle 6.14
Description
          Checks that 
        
catch parameter names conform to a specified pattern.
        Default pattern has the following characteristic:
- allows names beginning with two lowercase letters followed by at least one uppercase or lowercase letter
 - allows 
eabbreviation (suitable for exceptions end errors) - allows 
exabbreviation (suitable for exceptions) - allows 
tabbreviation (suitable for throwables) - allows 
_for unnamed catch parameters - prohibits numbered abbreviations like 
e1ort2 - prohibits one letter prefixes like 
pException - prohibits two letter abbreviations like 
ieoree - prohibits any other characters than letters
 
Properties
Examples
To configure the check:
<module name="Checker">
  <module name="TreeWalker">
    <module name="CatchParameterName"/>
  </module>
</module>
Example:
public class Example1 {
  public void myTest() {
    try {
      throw new InterruptedException();
    } catch (ArithmeticException e) {
    } catch (ArrayIndexOutOfBoundsException ex) {
    } catch (IndexOutOfBoundsException e123) {
      // violation above, 'Name 'e123' must match pattern'
    } catch (NullPointerException ab) {
      // violation above, 'Name 'ab' must match pattern'
    } catch (ArrayStoreException abc) {
    } catch (InterruptedException aBC) {
      // violation above, 'Name 'aBC' must match pattern'
    } catch (RuntimeException abC) {
    } catch (Exception EighthException) {
      // violation above, 'Name 'EighthException' must match pattern'
    } catch (Throwable t) {
    }
  }
}
An example of how to configure the check for names that begin with a lower case letter, followed by any letters or digits is:
Configuration:
<module name="Checker">
  <module name="TreeWalker">
    <module name="CatchParameterName">
      <property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
    </module>
  </module>
</module>
Example:
public class Example2 {
  public void myTest() {
    try {
      throw new InterruptedException();
    } catch (ArithmeticException e) {
      // violation above, 'Name 'e' must match pattern'
    } catch (ArrayIndexOutOfBoundsException ex) {
    } catch (IndexOutOfBoundsException e123) {
    } catch (NullPointerException ab) {
    } catch (ArrayStoreException abc) {
    } catch (InterruptedException aBC) {
    } catch (RuntimeException abC) {
    } catch (Exception EighthException) {
      // violation above, 'Name 'EighthException' must match pattern'
    } catch (Throwable t) {
      // violation above, 'Name 't' must match pattern'
    }
  }
}
Example of Usage
Violation Messages
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
Package
com.puppycrawl.tools.checkstyle.checks.naming






