public class ForbidThrowAnonymousExceptionsCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
This Check warns on throwing anonymous exception.
Examples:
catch (Exception e) {
throw new RuntimeException() { //WARNING
//some code
};
}
catch (Exception e) {
RuntimeException run = new RuntimeException() {
//some code
};
throw run; //WARNING
}
The distinguishing of exception types occurs by
analyzing variable's class's name.| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY
Warning message key.
|
| Constructor and Description |
|---|
ForbidThrowAnonymousExceptionsCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
setExceptionClassNameRegex(String exceptionClassNameRegex)
Setter for pattern.
|
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST literalThrowOrVariableDefAst) |
beginTree, clearMessages, destroy, finishTree, 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 void setExceptionClassNameRegex(String exceptionClassNameRegex)
exceptionClassNameRegex - The regular expression to set.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 visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST literalThrowOrVariableDefAst)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2021. All rights reserved.