异常由本行抛出
https://github.com/clojure/clojure/blob/clojure-1.9.0/src/jvm/clojure/lang/ExceptionInfo.java#L31
由于此调用
https://github.com/clojure/spec.alpha/blob/spec.alpha-0.1.143/src/main/clojure/clojure/spec/test/alpha.clj#L279
如果 `when-not` 返回 nil,则在 31 行抛出 `ExceptionInfo` 异常。
一个简单的修复可能是
(apply ex-info (remove nil? (link: "基于规范检查失败" (when-not ...))))
尽管这只是在掩饰问题,并没有为失败者提供任何可操作的信息。
遗憾的是,我没有最小的测试用例,因为这代码是专有的(且很复杂)。
或许作者在阅读代码后会更有见解。
以下是完整的堆栈跟踪
(链接:[clojure.lang.ExceptionInfo "ExceptionInfo.java" 31] [链接:clojure.lang.ExceptionInfo "ExceptionInfo.java" 22] [链接:clojure.core$ex_info invokeStatic "core.clj" 4739] [链接:clojure.core$ex_info invoke "core.clj" 4739] [链接:clojure.spec.test.alpha$explain_check invokeStatic "alpha.clj" 277] [链接:clojure.spec.test.alpha$explain_check invoke "alpha.clj" 275] [链接:clojure.spec.test.alpha$check_call invokeStatic "alpha.clj" 295] [链接:clojure.spec.test.alpha$check_call invoke "alpha.clj" 285] [链接:clojure.spec.test.alpha$quick_check$fn__2986 invoke "alpha.clj" 308] [链接:clojure.lang.AFn applyToHelper "AFn.java" 154] [链接:clojure.lang.AFn applyTo "AFn.java" 144] [链接:clojure.core$apply invokeStatic "core.clj" 657] [链接:clojure.core$apply invoke "core.clj" 652] [链接:clojure.test.check.properties$apply_gen$fn__16139$fn__16140 invoke "properties.cljc" 30] [链接:clojure.test.check.properties$apply_gen$fn__16139 invoke "properties.cljc" 29] [链接:clojure.test.check.rose_tree$fmap invokeStatic "rose_tree.cljc" 77] [链接:clojure.test.check.rose_tree$fmap invoke "rose_tree.cljc" 73] [链接:clojure.test.check.generators$fmap$fn__9199 invoke "generators.cljc" 101] [链接:clojure.test.check.generators$gen_fmap$fn__9173 invoke "generators.cljc" 57] [链接:clojure.test.check.generators$call_gen invokeStatic "generators.cljc" 41] [链接:clojure.test.check.generators$call_gen invoke "generators.cljc" 37] [链接:clojure.test.check$quick_check invokeStatic "check.cljc" 94] [链接:clojure.test.check$quick_check doInvoke "check.cljc" 37] [链接:clojure.lang.RestFn invoke "RestFn.java" 425] [链接:clojure.lang.AFn applyToHelper "AFn.java" 156] [链接:clojure.lang.RestFn applyTo "RestFn.java" 132] [链接:clojure.core$apply invokeStatic "core.clj" 657] [链接:clojure.core$apply invoke "core.clj" 652] [链接:clojure.spec.gen.alpha$quick_check invokeStatic "alpha.clj" 29] [链接:clojure.spec.gen.alpha$quick_check doInvoke "alpha.clj" 27] [链接:clojure.lang.RestFn applyTo "RestFn.java" 137] [链接:clojure.core$apply invokeStatic "core.clj" 661] [链接:clojure.core$apply invoke "core.clj" 652] [链接:clojure.spec.test.alpha$quick_check invokeStatic "alpha.clj" 309] [链接:clojure.spec.test.alpha$quick_check invoke "alpha.clj" 302] [链接:clojure.spec.test.alpha$check_1 invokeStatic "alpha.clj" 335] [链接:clojure.spec.test.alpha$check_1 invoke "alpha.clj" 323] [链接:clojure.spec.test.alpha$check$fn__3005 invoke "alpha.clj" 411] [链接:clojure.core$pmap$fn__8105$fn__8106 invoke "core.clj" 6942] [链接:clojure.core$binding_conveyor_fn$fn__5476 invoke "core.clj" 2022] [链接:clojure.lang.AFn call "AFn.java" 18] [链接:java.util.concurrent.FutureTask run "FutureTask.java" 266] [链接:java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1149] [链接:java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 624] [链接:java.lang.Thread run "Thread.java" 748])