arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Introduction

A Java library to handle success and failure without exceptions

hashtag
Handle success and failure in Java without exceptions

Wave goodbye to slow exceptions and embrace clean, efficient error handling by encapsulating operations that may succeed or fail in a type-safe way.

rocket-launchStart here githubFork me on GitHub

circle-check

Result is a Java library for modeling operation outcomes explicitly. It gives you a simpler, faster alternative to exception-driven flow when you want to represent both success and failure in a single, composable type.

hashtag
Why Result?

Optional is great for values that may be present or absent, but it does not explain why something is missing. Result fills that gap by carrying either a successful value or a failure reason, so your code can describe what happened instead of hiding it.

hashtag
Quick Start

1

Create a result from an operation

2

Inspect whether it succeeded or failed

3

Transform it if needed, then unwrap it as required

hashtag
Latest Releases

Available in

hashtag
Add-Ons

Integrate Result with popular libraries.

hashtag
Demo Projects

Try it for yourself in 5 minutes.

hashtag
Features

hashtag
Ready to Tap into the Power of Results?

Read the guide and transform your error handling today.

Also available as an ebook in multiple formats.

hashtag
TL;DR

Not a fan of reading long docs? No worries! Tune in to Deep Dive, a podcast generated by . In just a few minutes, you'll get the essential details and a fun intro to what this library can do for you!

Result<User, Exception> result = Results.ofCallable(() -> db.getUser(id));
result.ifFailure(error -> logger.error("Couldn't get user: {}", id, error));
String name = result.mapSuccess(User::name).orElse("Anonymous");
<dependencies>
    <dependency>
        <groupId>com.leakyabstractions</groupId>
        <artifactId>result</artifactId>
        <version>1.0.0.0</version>
    </dependency>
</dependencies>
dependencies {
    implementation("com.leakyabstractions:result:1.0.0.0")
}
arrow-up-right
🌱Getting Startedchevron-right
🪴Basic Usagechevron-right
🚀Advanced Usagechevron-right
Download your free copy now!arrow-up-right
NetbookLMarrow-up-right
Mental Model

Works with

Works with

Assert results fluently with

Serialize results to JSON with

Works with

Works with

Boost Performance

Avoid exception overhead and benefit from faster operations

Simple API

Leverage a familiar interface for a smooth learning curve

Streamlined Error Handling

Handle failure explicitly to simplify error propagation

Safe Execution

Ensure safer and more predictable operation outcomes

Enhanced Readability

Reduce complexity to make your code easier to understand

Functional Style

Embrace elegant, functional programming paradigms

Lightweight

Keep your project slim with no extra dependencies

Open Source

Enjoy transparent, permissive Apache 2 licensing

Pure Java

Seamless compatibility from JDK8 to the latest versions

Maven Central repository
Maven
Maven
Gradle
Gradle
AssertJ
AssertJ
Jackson
Jackson
Spring Boot
Micronaut
Micronaut
Because exceptions are so last century.
Because exceptions are so last century.
For a smooth ride from Optional to Result.
For a smooth ride from Optional to Result.
Say goodbye to error-handling acrobatics.
Say goodbye to error-handling acrobatics.
Skip the exception rollercoaster and enjoy the smooth ride.
Skip the exception rollercoaster and enjoy the smooth ride.
So you can actually understand your own code next month.
So you can actually understand your own code next month.
For those who prefer elegance over chaos.
For those who prefer elegance over chaos.
Because bloated libraries are so overrated.
Because bloated libraries are so overrated.
Feel free to tweak and share — no strings attached.
Feel free to tweak and share — no strings attached.
Whether you're stuck in the past or embracing the future, we've got you covered.
Whether you're stuck in the past or embracing the future, we've got you covered.