Files
codeql/csharp/ql/src/Language Abuse/RethrowException.ql
2019-01-02 12:59:07 +01:00

31 lines
790 B
Plaintext

/**
* @name Rethrowing exception variable
* @description Throwing the exception variable will lose the original stack information.
* This can make errors harder to diagnose.
* @kind problem
* @problem.severity warning
* @precision very-high
* @id cs/rethrown-exception-variable
* @tags maintainability
* language-features
* exceptions
*/
import csharp
CatchClause containingCatchClause(Stmt s) {
result.getBlock() = s
or
exists(Stmt mid |
result = containingCatchClause(mid) and
mid.getAChildStmt() = s and
not mid instanceof CatchClause
)
}
from SpecificCatchClause cc, ThrowStmt throw
where
throw.getExpr() = cc.getVariable().getAnAccess() and
containingCatchClause(throw) = cc
select throw, "Rethrowing exception variable."