exceptional

Simplifying exception handling: checked exceptions become unchecked, and preconditions are demanded where they hold.

Converts checked exceptions to runtime exceptions and provides explicit condition and non-null checks. Use it where the caller has chosen to propagate failure without a checked throws clause.

Key Concepts

Exception conversion

Role. tosser(Exception) returns a RuntimeException unchanged or wraps another Exception in a RuntimeException with the original as its cause. toss(Exception) throws that result.

Calling checked operations

Role. yoda(Callable) returns the callable's result. If the call throws an Exception, yoda throws the converted runtime exception. Errors propagate unchanged.

Demand checks

Role. demand(BooleanSupplier) evaluates the condition once and throws DemandFailedException if it is false. An overload accepts a message. fixHoaresBillionDollarMistake(value) returns a non-null value unchanged or throws DemandFailedException.

How It Works

Guarantees. Place demand checks at the point that requires a condition. Call yoda around a checked operation when runtime propagation is the intended boundary, or throw tosser from an existing catch block.

Usage

Read a supplied file while propagating I/O failure as a runtime exception

import java.nio.file.Files;
import java.nio.file.Path;
import software.visionary.exceptional.Exceptional;

public class ReadWithoutCheckedClause {
    public static void main(String[] args) {
        Exceptional.demand(() -> args.length == 1, "Supply one file path");
        String path = Exceptional.fixHoaresBillionDollarMistake(args[0]);
        String text = Exceptional.yoda(() -> Files.readString(Path.of(path)));
        System.out.println(text);
    }
}

Dependencies

  • software.visionary.contrax:enforcements:2026.10.13 at Processor
  • software.visionary:junit-closure:2026.10.13 at Testing

Caveats

  • Checked exceptions are wrapped, not rethrown with their original runtime type. A caller inspecting a wrapped failure uses its cause.

Views

Drawn from the release. A link in a view opens its source at the release tag.

architecture.svg
architecture.svg
classes.software.visionary.exceptional.svg
classes.software.visionary.exceptional.svg
packages.svg
packages.svg