Skip to content

Instantly share code, notes, and snippets.

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.leonov.config</groupId>
<artifactId>optional-config</artifactId>
<version>1.4.3RC1</version>
<name>Optional Config</name>
// public API method
public void someMethod() throws Exception {
try {
// some work happens here, maybe not my code
} catch (final Throwable t) {
if(t instanceof Exception || t instanceof Error)
// if t is an Exception or a RuntimeException the method signature already declares it
// if t is an Error then it is not a checked exception in the first place
throw UnsafeUtil.unchecked(t);
else