Architecture Weekly
Read post

Throw, Result, or neither?

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

A deep dive into error handling strategies in event-sourced systems, arguing that returning business failures as domain events is often preferable to throwing exceptions or using Result types. Using a shopping cart example in TypeScript with the Emmett framework, the author demonstrates how events like ProductItemOutOfStock and ShoppingCartItemLimitReached can carry richer business data than exceptions or Result wrappers. The post covers selective persistence (deciding whether to append an event to the stream), batch command handling with atomic vs. non-atomic semantics, and Emmett's middleware helpers (rejectOn, skipOn, stopOn, stopAfter, throwOn) that let the same decision function behave differently across use cases like HTTP endpoints, cart imports, and saved-list restores. Exceptions are still used for invalid operations and infrastructure failures, while Result types are critiqued for adding propagation overhead without replacing the persistence and continuation decisions that event types already encode.

    #architecture#typescript#domain-driven-design
Jul 20•24m read time•From architecture-weekly.com
Post cover image
Table of contents
A business fact becomes an eventBroken rules throwWhat Result would addProducing an event is not persisting itHandling choices in EmmettSeveral decisions on one streamMapping Events to Error ResponseRetries and asynchronous handlersConclusion
73.6K Impressions
Architecture Weekly's image
Architecture Weekly

Architecture Weekly's publication is a central hub for architecture enthusiasts, offering insights i...

255 Followers

•

1.5K Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard