Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 644 Bytes

ThrowExceptionFromFinallyBlock.md

File metadata and controls

25 lines (18 loc) · 644 Bytes

Pattern: Exception throw from finally block

Issue: -

Description

Checks for throwing an exception from within a finally block. Throwing an exception from a finally block is confusing and can hide the original exception.

Here is an example of code that produces a violation:

int someMethod() {
    try {
        doSomething()
        throw new Exception()
    } finally {
        println 'finally'
        throw new Exception()   // violation
    }
}

Further Reading