-
Notifications
You must be signed in to change notification settings - Fork 51
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
Custom formatter for ex-info thrown by cljs.spec #23
Comments
I like your idea. But how do you think cljs-devtools could implement this without this feature being framework-specific? |
Ok, thinking about this more. We could install [1]
|
That sounds like a good approach. I guess the other possibility is to extend IFormat for ExceptionInfo and use ex-data to enable special treatment. |
To keep the ball rolling, I have just tested ExceptionInfo behaviour[1]. Currently cljs-devtools has pretty nice behaviour, it presents the error printed with IPrintWithWriter protocol[2]. The implementation is questionable because they are re-implementing clojurescript map printer in there, but that is not essential to our issue at hand. I think nothing is stopping you overriding IPrintWithWriter on ExceptionInfo and doing something better there (e.g. abbreviating long messages). But I agree that we could do even better job with IFormat. We could reuse string abbreviation logic already implemented[3] in devtools and present other parts as expandable data. [1] binaryage/cljs-devtools-sample@6422ec1
|
Actually this I went down the rabbit hole and proposed a solution upstream: Let's wait for its resolution before moving forward. |
Interesting. Thanks. (I'd love to know what Bruce is thinking about presenting spec errors. Can't help but think he'll be the trendsetter.) |
This would be a killer feature! |
Currently it's quite tricky to get good output from cljs.spec. Reason being that the ex-info thrown includes the full spec commentary in ex-message. This includes the serialised val which failed. In my case this can fill the console many times over.
Alex Miller recommended catching these exceptions and using the ex-data to present the spec nicely. (e.g. don't print the ex-message to the console). This would be fine except it's difficult to catch all errors due to the nature of how UI code executes (react render loop, re-frame dispatch queue, callbacks)
How about automatically detecting and pretty formatting ex-info errors thrown by cljs.spec?
The text was updated successfully, but these errors were encountered: