144
144
145
145
Takes the same options as pinpoint."
146
146
([ed] (pinpoint-out ed {}))
147
- ([ed {:keys [width colorize fallback-on-error eval] :as opts
148
- :or {width 70 , fallback-on-error true }}]
147
+ ([ed {:keys [width colorize eval fallback-on-error fallback-reporting-fn] :as opts
148
+ :or {width 70
149
+ fallback-on-error true
150
+ fallback-reporting-fn (fn [_]
151
+ (println (str " [PINPOINTER] Failed to analyze the spec errors, "
152
+ " and will fall back to s/explain-printer\n " )))}}]
149
153
(if ed
150
154
(let [{:keys [::s/problems ::s/value ] :as ed'} (correct-paths ed)
151
155
nproblems (count problems)
171
175
" :" (:line caller) " )" )))))
172
176
173
177
fallback-on-error
174
- (do (println " [PINPOINTER] Failed to analyze the spec errors, and will fall back to s/explain-printer\n " )
178
+ (do (fallback-reporting-fn {:explain-data ed
179
+ :exception traces})
175
180
(s/explain-printer ed))
176
181
177
182
:else (throw traces)))
@@ -190,6 +195,9 @@ The opts map may have the following keys:
190
195
:fallback-on-error - If set to true, falls back to
191
196
s/explain-printer in case of an error during the analysis.
192
197
Otherwise, rethrows the error. Defaults to true.
198
+ :fallback-reporting-fn - A fn (which takes as an argument a map with `:explanation-data` and `:exception` keys)
199
+ which reports that pinpointer is falling back to clojure.spec
200
+ to reports error. Defaults to a println with a fixed message.
193
201
:eval - eval fn to be used to analyze spec errors. Defaults to
194
202
clojure.core/eval in Clojure, nil in ClojureScript."
195
203
([spec x] (pinpoint spec x {}))
0 commit comments