Open vemv opened 5 years ago
Specific example:
:db.error/past-tx-instant Time conflict: Thu Apr 25 04:26:57 CEST 2019 is older than database basis
Tells you nothing about the transaction that failed. That forces one to go on a hunt for the culprit.
A good place to fix this would be in the implicit deref
ing. As mentioned, we will do derefing within the library.
So the call to deref
can be extended to:
(let [tx-data ...
tx (transact conn tx-data)]
(try
@tx
(catch Exception e
(throw (ex-info "Oops" {:original-exception e
:tx-data tx-data})))))
Furthermore, if we detect that e
matches :db.error/past-tx-instant
, we can get the latest transaction and print it. i.e we show the old transaction that caused the new one to fail.
Problem statement
deref
thed/transact
result is error-pronePossible solution
Create a wrapper backed by utils.spec.
Non-goals
Create an abstraction or convenience layer over Datomic. API should remain 99% as-is.
Considerations
1.-
clojure.test/*assert*
should be observed; if false, most development niceties should be disabled2.-
I found the following pattern in the wild:
The distinction is useful but ad-hoc. The following naming:
Would lead to non-ad-hoc aliases:
i.e., we can make things homogeneous and unmistakable.