public class CauseParameterInExceptionCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
Rationale:
"A special form of exception translation called exception chaining is
appropriate in cases where the lower-level exception might be helpful to
someone debugging the problem that caused the higher-level exception. The
lower-level exception (the cause) is passed to the higher-level.."
[Joshua Bloch - Effective Java 2nd Edition, Chapter 4, Item 61]
Parameters:
| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
CauseParameterInExceptionCheck()
Creates the new check instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST) |
void |
finishTree(com.puppycrawl.tools.checkstyle.api.DetailAST treeRootAST) |
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
setAllowedCauseTypes(String... allowedCauseTypes)
Sets the names of classes which would be considered as Exception cause.
|
void |
setClassNamesRegexp(String classNamesRegexp)
Sets the regexp for the names of classes, that should be checked.
|
void |
setIgnoredClassNamesRegexp(String ignoredClassNamesRegexp)
Sets the regexp for the names of classes, that should be ignored by
check.
|
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) |
clearMessages, destroy, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeveritypublic static final String MSG_KEY
public CauseParameterInExceptionCheck()
public void setClassNamesRegexp(String classNamesRegexp)
classNamesRegexp - String contains the regex to set for the names of classes, that
should be checked.public void setIgnoredClassNamesRegexp(String ignoredClassNamesRegexp)
ignoredClassNamesRegexp - String contains the regex to set for the names of classes, that
should be ignored by check.public void setAllowedCauseTypes(String... allowedCauseTypes)
allowedCauseTypes - - the list of classNames separated by a comma. ClassName should be
short, such as "NullpointerException", do not use full name -
java.lang.NullpointerException;public int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
beginTree in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void finishTree(com.puppycrawl.tools.checkstyle.api.DetailAST treeRootAST)
finishTree in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2021. All rights reserved.