How to detect CAS errors with version 0.9.5661


#1

I was under the impression that I could detect CAS errors with something like this:

(if (= (:cognitect.anomalies/category (ex-data t)) :cognitect.anomalies/conflict)
  ...)

But with Datomic 0.9.5661, I need to do this:

(if (= :db.error/cas-failed (:db/error (ex-data (.getCause e))))
  ...)

Was the anomaly keys introduced in a later version? Am I going to encounter an issue when I upgrade to a later version of Datomic?


#2

Are you using Client or Peer?

Peer doesn’t (currently) use anomalies, as they were introduced with the Client API.


#3

Ah! I’m using peer and didn’t realize I was reading the cloud documentation :slight_smile:

Is my second code block the right way to detect CAS failures on on-prem peers?

Thanks for the quick answer.


#4

Yes, detecting the cas-failed exception would be the way to identify CAS failures in On-Prem.