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

Pretty print error logging #360

Open
danielcompton opened this issue May 23, 2016 · 7 comments
Open

Pretty print error logging #360

danielcompton opened this issue May 23, 2016 · 7 comments

Comments

@danielcompton
Copy link

The error messages printed by schema are sometimes quite tricky to parse, for example:

outstanding-queries

The schema that generated it was quite simple:

(def outstanding-query
  {:token  UUID
   :query  {s/Keyword s/Any}
   :out-ch async-protocols/WritePort
   :err-ch async-protocols/WritePort})

but it is very difficult to understand which part doesn't match the schema, and importantly, what the actual value is if it's not matching the schema.

Pretty printing the message in the ex-info would be quite helpful, however I suspect part of the responsibility for pretty printing this might actually fall to the user (e.g. me) to catch and pretty print the data in the ex-info?

@w01fe
Copy link
Member

w01fe commented May 23, 2016

As you mention, I think this is beyond the scope of what we'd want to put in schema.core. But I think there are already other libraries/plugins that do precisely what you want (pretty-print the ex-info) -- In particular, maybe look at io.aviso/pretty ?

@danielcompton
Copy link
Author

I think you're right, the responsibility probably lies elsewhere. Thanks!

@danielcompton
Copy link
Author

danielcompton commented May 23, 2016

Although, in saying that, should the message still be pretty printed? There's no easy way for anyone downstream to pretty print that. This is in ClojureScript btw.

@danielcompton danielcompton reopened this May 23, 2016
@w01fe
Copy link
Member

w01fe commented May 23, 2016

Point taken, thanks. A PR to pretty-print the message body would be welcome.

@philomates
Copy link
Contributor

This is a least partially solved with #383 and #386

@jmlsf
Copy link

jmlsf commented May 17, 2018

It appears that the two patches mentioned in the previous comment add TTY codes to the message output. I suppose the intent here is that in a Clojure environment this would eventually go to a TTY-based repl? My question is: what is the intended use in ClojureScript when the ExceptionInfo typically gets thrown and printed to the console. A typical message will look something like the following, with all of the TTY codes just converted to plaintext: "Input to notebook-contents-received does not match schema: ↵↵ �[0;33m [nil nil (not (map? a-object))] �[0m ↵↵" Is there a better way to view error messages in ClojureScript?

@w01fe
Copy link
Member

w01fe commented May 18, 2018

I haven't actually used Schema in cljs for some time, but hopefully someone else will have an answer. If not I'd be open to making this configurable, would just need to think about the best way to do so ...

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

4 participants