Closed msassak closed 4 years ago
To illustrate what I mean about Clojure's pre and post conditions:
=> (defn y [a] {:pre [(number? a)]} a)
#'user/y
=> (y 123)
123
=> (y "123")
Execution error (AssertionError) at user/y (form-init3166981006581329906.clj:1).
Assert failed: (number? a)
=> (isa? (type *e) Exception)
false
=> (isa? (type *e) Throwable)
true
Makes sense. Let me create a fix for this.
@msassak could you please check if https://github.com/sunng87/diehard/commit/4628fa5cd563be148c4fc5862ecf4c6db35a93a6 work for you?
@sunng87 I verified it works. Thank you!
Thank you for quick verification.
Currently the release was blocked by a leiningen issue. I will release a new version once it fixed.
released in 0.9.3
Currently diehard restricts retry-on to
Exception
and its subclasses:https://github.com/sunng87/diehard/blob/master/src/diehard/spec.clj#L17
This is in keeping with the recommendation from the Java docs:
https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html
But this advice is (sadly) contradicted by experience. In the wild, much code throw exceptions that are not subclasses of
Exception
(Clojure's pre and post assertions, for example) or catchesThrowable
, usually in a server context to prevent thread death, for example:As diehard is used in exactly these situations, I believe the spec should be relaxed to
(isa? % Throwable)
.