Oscar Ablinger
1 min readJan 25, 2022

Yeah, it’s actually pretty much the standard with more functional programming. Sadly, I haven’t had the chance to try it out much in Java (only in certain areas) since I wouldn’t actually try to rewrite/wrap all of Java’s standard APIs and libraries that use Exceptions.

But the place where I have tried it are streams, JavaScripts promises and of course the few “functional” languages that I’ve tried.

If you want to see it in action, you could just look at any Rust program as that’s the only way that Rust allows you to handle errors short of completely halting the program.

How it works is described here: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html
In the case of rust it’s combined with discriminated unions (or just enums in rust). That has advantages and disadvantages of course, but the idea stays the same: the returned type encompasses both the successful as well as the exceptional case.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Oscar Ablinger
Oscar Ablinger

Written by Oscar Ablinger

Hi, I’m a Software Engineer that just writes on here about whatever he finds out in a given week. Could be scripts, insights or explanations of things I learned

No responses yet

Write a response