FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Stop Throwing Exceptions. Use Option and Result Instead.
How-ToWeb Development

Stop Throwing Exceptions. Use Option and Result Instead.

via Dev.to JavaScriptVitali Haradkou1mo ago

Let's talk about what's wrong with JavaScript error handling. Here's a function: function getUser ( id : number ): User | null { // ... } The caller has to remember to null-check. The type system nudges them, but there's nothing stopping this: const user = getUser ( 42 ); console . log ( user . name ); // TypeError at runtime if user is null Or this pattern, which is even worse: async function fetchConfig (): Promise < Config > { // can throw network error, parse error, validation error... // none of these appear in the type signature } The errors are invisible. The caller doesn't know what to handle. There's a better model Rust has Option<T> for values that might not exist, and Result<T, E> for operations that can fail. Both are explicit in the type signature . Both force the caller to handle every case. @rslike/std brings this to TypeScript. npm i @rslike/std Option — make absence impossible to ignore import { Some , None , Option , match } from " @rslike/std " ; function findUser (

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
39 views

Related Articles

Week 6 — No New Problems. Just Me and Everything I Already Learned.
How-To

Week 6 — No New Problems. Just Me and Everything I Already Learned.

Medium Programming • 2d ago

What OpenClaw Gets Wrong Out of the Box (And How to Fix It)
How-To

What OpenClaw Gets Wrong Out of the Box (And How to Fix It)

Medium Programming • 2d ago

Android Remote Compose:讓 Android UI 不用發版也能更新
How-To

Android Remote Compose:讓 Android UI 不用發版也能更新

Medium Programming • 2d ago

How-To

Learn Something Old Every Day, Part XVIII: How Does FPU Detection Work?

Lobsters • 3d ago

“Learn to Code” Is Dead… Learn to Think Instead
How-To

“Learn to Code” Is Dead… Learn to Think Instead

Medium Programming • 3d ago

Discover More Articles