greggyb,
@greggyb@mastodon.sdf.org avatar

I came up with a thing in today and I am unsure about it. I don't know if it's cute, useless, or useful; I cannot see far enough ahead to understand its implications.

type ErrExn = | Err of DomainError | Exn of System.Exception

This DU unifies domain errors (that are represented in a user-written DU) and exceptions.

I'd expect it to be in a function with a signature of 'a -> Result<'b, ErrExn>.

I don't know if this gives value over separate domain errors and exceptions.

Thoughts?

chethusk,
@chethusk@hachyderm.io avatar

@greggyb @pblasucci has written about this in the past, but he's generally not a fan of lifting exceptions into unions like this. I think the advice goes like either convert a localized exception into a domain error that is meaningful, or let it bubble up and crash

pblasucci,
@pblasucci@hachyderm.io avatar

@chethusk @greggyb Mostly right, Chet. 😉
The only other scenario is to actually trap and handle the exception (eg: retry a db contention issue). In the retry case, the exception is neither converted nor percolated. But otherwise, yeah. Totally agree.👍

giuliohome,
@giuliohome@mastodon.world avatar

@pblasucci @chethusk @greggyb
In the retry case, according to temporal workflow philosophy, it would be an exception, a retriable exception, possibly with exponential backoff, managed by the workflow platform. And nobody wants to reinvent the wheel, sadly imho.
One starts as f# programmer and ends up working in a python project team. And they say it's "typed" and has "compile time" checks, due to LSP magic, openai generated domain classes and the like.
We're in the YAML and AI era.
¯_(ツ)_/¯

giuliohome,
@giuliohome@mastodon.world avatar

@pblasucci @chethusk @greggyb
"Let it bubble up and crash" is also more in line with and modern 10 factor app principles.
It's not "crash" though, it is "shut down gracefully"
For a worker , graceful shutdown is achieved by returning the current job to the work .

johnefrancis,
@johnefrancis@mastodon.social avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • anitta
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • provamag3
  • tester
  • Leos
  • megavids
  • JUstTest
  • All magazines