Fork me on GitHub
#clojure
<
2023-12-21
>
hifumi12304:12:25

What error handling patterns do people prefer when it comes to consuming “company internal” library functions in an application? I am considering returning keywords for various failure modes, like Datomic does with cognitect.anomalies, but I also find value in letting the caller explicitly handle exceptions and nil return values. For context: this function I am dealing with parses an XML document and uses zippers to find data with a certain shape then return an attribute of an element in that data. --- question rephrased briefly: do you prefer propagating errors to callers or wrapping them in “nicer” interfaces?

jjttjj13:12:57

My interpretation is that anomalies are more for propagating errors in distributed systems. If you have a large data center and something runs out of disk space, just throwing an exception on that machine alone isn't helpful, you need to send some data somewhere. But for your usage of a low level library I'd default to just throwing exceptions. You can always catch them and turn them into anomalies later.

👍 1
Daniel Sunnerek19:12:28

For me it sounds like if there is a clear API between library code and consumers. And the API / business logic is well known defined. Maybe it's worth returning keywords as you would do with an http API. A long time ago I played around with hierarchical failure modes. Sounds a bit like what you are talking about. Project is old but maybe https://github.com/kardan/taxa can be of some kind of inspiration. If you decide to go down that path.

Mateusz Mazurczak18:12:12

Hi, any idea why my taps are not returning any data to the portal window, unless I first print the value? From what I read it should evaluate the data at the same time of tap>, so even if it's lazy it should be visible there.

hiredman18:12:02

Sure sounds like you have a lazy-seq that calls tap> somewhere so that tap> doesn't happen until the seq is realized, which printing it would do

hiredman18:12:56

hard to say, not sure what all you mean

hiredman18:12:00

what I am saying is you have something like (map (fn [i] (tap> i)) '(1 2 3)) that produces a lazy seq, so the tapping of i won't happen until the seq is realized

hiredman18:12:32

what is seems like you are asking about is (tap> x) where x is a lazy seq(something like that is what I take "realized at tap>" to mean), which doesn't match the symptoms you described, the lazy seq with tapping does

hiredman18:12:11

a thing about printing is it can force multiple levels of lazy seqs

Samuel Ludwig19:12:40

we might wanna take this one out 😅

😂 4
Samuel Ludwig19:12:25

they went defunct semi-recently, think there were some accounts of fraud business?

Samuel Ludwig19:12:29

In March 2023, after central bank–endorsed interest rate hikes during the 2021–2023 inflation surge,[12][13][14][15] there was a bank run on its deposits, which led to its collapse and seizure on March 10, 2023 by the California Department of Financial Protection and Innovation (DFPI), its regulator.[16] Citing inadequate liquidity and insolvency, state officials at the DFPI appointed the Federal Deposit Insurance Corporation (FDIC) receiver of the bank.[16][17] This was, at the time, the second-largest bank failure in U.S. history, later surpassed by the collapse of First Republic Bank during the March 2023 United States bank failures.

p-himik19:12:10

Ah, I would just mention that they've been acquired/seized by someone, whatever the right terminology might be. No need to completely remove the entry, there are already similar things in there, like Braintree Payments (acquired by PayPal).

Samuel Ludwig19:12:32

fair fair fair simple_smile

seancorfield19:12:01

SVB are still in business. Chapter 11 doesn't mean they've gone away). There are several companies on that list that have ceased to exist or got acquired/changed their names.

Samuel Ludwig19:12:22

thats fair, i just recall it being a pretty high-profile failure at the time

Alex Miller (Clojure team)00:12:33

well I don't think Clojure code was to blame :)

1
4
👍 1
Jason Bullers18:12:53

No, but I guess the point is kind of "by association". Hey, look who uses Clojure! This bank that tanked because of shady business practices and took everyone's money with them. Not exactly endorsement material, regardless of how solid the tech may have been. :man-shrugging::skin-tone-2: Doesn't really bother me though

Jason Bullers19:12:13

Did FTX use Clojure too? 😂