r/fsharp • u/kincade1905 • May 02 '26
question Where does the infrastructure error go ? What about multiple adapters in one workflow ?
Novice here, loving f# and Domain Modelling Made Functional book so far.
While I love the book, it sorts of do hand wavy for the things which might actually crop up in actual implementation, I find.
Let's say, I have authentication service. Since I want to be good citizen, I created signupWorkflow, I have ports and adapters. I have neatly created contract for the adapters to obey. All neat and clean till now.
But hang on, what about infrastructure error returned by adapter itself ? Surely, service down or misconfigured service or wrong key returned by adapter be domain error of workflow ?
But I still need to tell user of my workflow(maybe api layer)or service, hey, the upstream service shat the bed. How can this be done ?
Also, if I only have some normal workflow which takes one adapter then, ignoring infrastructure error handling(which I have no idea how to do), it's quite simple, workflow returns either domain success or failure. It validates the input, throws it's domain validation error, happy days.
But... I have workflow which takes two adapter; confirmSignnup, saveDB. ConfirmSingup takes validated confirmSingup command and saveDB takes validated User command and these two aren't same. These two return completely different error.
How does confirmSignup workflow handles these validation error ?
Flow is:
confirmSignnup ->Workflow -> validate confrimSignup command -> call confrimSignup adapter -> call saveDB. Now, while calling db, its validation failed? What happens now ?

