Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions aren't caught during check! #3

Open
vemv opened this issue Jun 4, 2019 · 0 comments
Open

Exceptions aren't caught during check! #3

vemv opened this issue Jun 4, 2019 · 0 comments

Comments

@vemv
Copy link
Contributor

vemv commented Jun 4, 2019

Bug report

Brief

Exceptions aren't caught when check! invokes the passed predicates.

Expected behavior

(check! pos? nil) is handled gracefully

Actual behavior

An error is thrown opaquely. Particularly, this makes speced/defn less useful

Reproduction steps

(check! pos? nil)

Screenshot, stacktrace, etc

unit.nedap.utils.speced.defn.destructuring> (check! pos? nil)
Execution error (NullPointerException) at unit.nedap.utils.speced.defn.destructuring/eval190893 (form-init2166769074214536620.clj:1).
null
#error {
 :cause nil
 :via
 [{:type java.lang.NullPointerException
   :message nil
   :at [clojure.lang.Numbers ops "Numbers.java" 1068]}]
 :trace
 [[clojure.lang.Numbers ops "Numbers.java" 1068]
  [clojure.lang.Numbers isPos "Numbers.java" 121]
  [clojure.core$pos_QMARK_ invokeStatic "core.clj" 1252]
  [clojure.core$pos_QMARK_ invoke "core.clj" 1247]
  [clojure.spec.alpha$spec_impl$reify__1987 conform_STAR_ "alpha.clj" 875]
  [clojure.spec.alpha$valid_QMARK_ invokeStatic "alpha.clj" 755]
  [clojure.spec.alpha$valid_QMARK_ invoke "alpha.clj" 751]

Environment info

Happens on any util.spec version


Tech improvement

Proposal

  • Catch the exception
  • Make Expound print something pretty
    • See nedap.utils.spec.impl.check

Alternatives and comparison

  • Let it fail opaquely
    • I don't see an advantage, other than maintaining less code
@thumbnail thumbnail transferred this issue from nedap/speced.def Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant