/ToRuntime

Promote checked exceptions to runtime exceptions

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

Download Build Status codecov

Improve test coverage by trapping and promoting tricky checked exceptions you don't really expect or can't handle.

Install

Use either of these repositories:

repositories {
    jcenter()
}

or:

repositories {
    maven {
        url 'https://dl.bintray.com/novacrypto/General/'
    }
}

Add dependency:

dependencies {
    compile 'io.github.novacrypto:ToRuntime:2019.01.27@jar'
}

Usage

Migrate from:

Result result;
try {
    result = somethingThatThrowsChecked();
} catch (TheChecked checked) {
    throw new RuntimeException(checked); // tricky to cover this line
}

To:

import static io.github.novacrypto.toruntime.CheckedExceptionToRuntime.toRuntime;
Result result = toRuntime(() -> somethingThatThrowsChecked());