Fork me on GitHub
#unrepl
<
2017-11-28
>
volrath10:11:21

hey @cgrand, I wonder what do you think about having special print-limits settings for exceptions, particulary print-length... cider lets you set print-length and print-level for exceptions, I'm not entirely sure print-level is useful, but I can see people wanting to customize exception's print-length (I do it in my cider config)

volrath10:11:44

also imo, string-length at 80 might be a bit short for exceptions, simple exception messages would get elided, like this one:

#unrepl/string ["java.lang.RuntimeException: Unable to resolve symbol: x in this context, compili" #unrepl/... {:get (unrepl.replG__16476/fetch :G__17055)}

pesterhazy10:11:18

👍 on the default

pesterhazy10:11:35

what would be a better default in your mind?

volrath10:11:34

I think for exceptions I would go for unrestricted string-length... print-length would mostly affect the trace vector, so I think it would be cool to make it customizable

pesterhazy10:11:14

I've seen ex-infos with ridiculous strings in it (where you pr-str your entire state)

volrath10:11:16

in general, i think the ideal would be to have exception print-limits separated from the rest

pesterhazy10:11:42

but maybe that's too niche

pesterhazy10:11:00

I think I tend to agree with you that it should be unlimited for exceptions

cgrand11:11:02

I agree with the premises: exceptions suck in unrepl

cgrand11:11:15

but exceptions are already bad on their own

cgrand11:11:51

Could we take a step back and consider how to make exceptions less bad

cgrand11:11:22

I lean towards, as a first step totally reversing exceptions: * display them bottom up * display them inside out (most wrapped exception first)

cgrand11:11:00

so that the line at the bottom is the closest to what occured and where

cgrand11:11:00

elide wrapped-by (the reverse of the parent exception relationship), elide previous frames, print ex-info when present

volrath11:11:44

right now, afaik, ex-info always comes from unrepl.repl/blame-ex, right? it's always something like: "Exception during foo phase"

cgrand11:11:14

that should be removed by the client

cgrand11:11:38

and display something only when it’s not during eval

volrath11:11:43

i agree, I'm actually doing that

cgrand11:11:58

Expression computed succesfully but failed to print

volrath11:11:10

I like that

cgrand11:11:21

Unreadable input

cgrand11:11:37

Sad unicorn (like sad mac, for when it comes from unrepl)

volrath11:11:38

but since the phase is already part of the message payload, couldn't we just take that ex-info out?

volrath11:11:03

I mean, from this part:

volrath11:11:07

:via
        [{:type clojure.lang.ExceptionInfo,
          :message "Exception during eval phase.",
          :data {:unrepl.replG__16476/ex #error {#unrepl/... nil #unrepl/... {:get (unrepl.replG__16476/fetch :G__17054)}},
                 :unrepl.replG__16476/phase :eval},
          :at [clojure.core$ex_info invokeStatic "core.clj" 4725]}
         {:type clojure.lang.Compiler$CompilerException,
          :message #unrepl/string ["java.lang.RuntimeException: Unable to resolve symbol: x in this context, compili" #unrepl/... {:get (unrepl.replG__16476/fetch :G__17055)}],
          :at [clojure.lang.Compiler analyze "Compiler.java" 6720]}
         {:type java.lang.RuntimeException,
          :message "Unable to resolve symbol: x in this context",
          :at [clojure.lang.Util runtimeException "Util.java" 221]}],

volrath11:11:44

(this is not what I was asking at the beginning of this, but I'm also curious)

volrath11:11:51

what I'm doing right now is just ommiting the first element in that vector, since I'm using the :phase to insert a exception title

cgrand11:11:39

@volrath: thanks, I forgot an x...

volrath11:11:11

perfect 🙂

volrath11:11:01

so ok, let me get back to what you were saying before and ask you some (probably noob) questions

volrath11:11:22

when you're saying "display the exceptions bottom up", are you talking client-wise or protocol-wise?

cgrand11:11:18

client-wise it’s going to be roundtrip-painful (unless you get the whole exception at once)

cgrand11:11:24

well bottom-up client side is ok, inside-out not

volrath11:11:22

can you explain the difference? not sure if I follow... right now I don't know how to get the wrapping information from the exception message payload. Not sure if it's because that information is not there or because I am missing something

cgrand11:11:27

ok I just realized that’s already what Throwable->map does

cgrand11:11:06

wrapping information is the :via vector

volrath11:11:36

But Throwable->map doesn't return the wrapping inside out, does it?

volrath11:11:06

what I'm doing right now is reverse that vector

pesterhazy12:11:14

Btw I've seen that exceptions get returned in different shapes on clojure 1.8 vs 1.9

volrath12:11:24

I guess as long as Throwable->map returns the same in both, we're good

dominicm12:11:19

@pesterhazy I think ./clj is the official answer to this

pesterhazy12:11:19

@dominicm is that bundled with clojure?

pesterhazy12:11:51

official instructions for doing things manually would be appreciated

cgrand12:11:03

0.1.143 for spec.alpha

cgrand12:11:21

core.specs.alpha 0.1.24

cgrand12:11:47

is there any effort to port tools deps to CLJS?

dominicm12:11:51

@cgrand none that I know of

pesterhazy14:11:16

@cgrand, oh the spec dep is right there on the mvn site facepalm

cgrand14:11:39

yeah but mvn central was down for me

cgrand17:11:14

v0.2.0 of packed printer with a cleaner implementation and works in CLJS too

cgrand18:11:56

I pushed to npm too

volrath20:11:39

@cgrand notice after resolving the first elision there are a couple of misalignments? I'm trying to pad the file name and lineno using the max length of what i can see in the :trace vector, but since it is elided, I cannot render it well

volrath20:11:07

but anyway, I think it's good enough for now

ghadi20:11:59

@volrath nice. since 1.8/direct linking every stack frame is doubled because of invoke+invokeStatic, would be cool to elide adjacent frames

volrath20:11:09

cool, thanks for the input! tbh I don't know much about this, could you point me to some info?

ghadi21:11:24

basically pre-clojure 1.8 functions got compiled into a java class that implemented a single method invoke()

ghadi21:11:10

Now with this direct-linking mode (which improves performance) the invoke() which is an instance method, calls down to an invokeStatic() which is a static class method. This results in longer stack frames

ghadi21:11:43

if you see a foo.invoke() that immediately calls foo.invokeStatic() in a stack trace, one of them should disappear

volrath21:11:19

got it, I'll look into it, thanks!

ghadi20:11:22

this is really really cool.

cgrand20:11:05

Nice, an intersting problem is how to deal with misalignment

volrath20:11:37

rerendering is a pain in the ass...

volrath20:11:14

@cgrand you never got to tell me your thoughts on managing print limits for exceptions separately

cgrand21:11:29

@volrath wider strings, yes

volrath21:11:19

higher/customizable *print-length*? that's the one I think could help the most

cgrand21:11:42

why? for the alignment?

volrath21:11:52

and for the elisions..

volrath21:11:16

clicking the buttons when getting an exception can get old really fast

volrath21:11:46

in the end, I think we should let the user decide what's best for their workflow

cgrand21:11:21

one setting for everything does not work

volrath21:11:39

even though I do believe that customization is the key of happiness, that's not my point... stacktraces are consumed by people in different ways

volrath21:11:13

I'm not saying a different print-limits management for every data type or anything like that

volrath21:11:25

but I feel this is something people should be able to customize. as we know, exceptions/stacktraces are not the best thing in clojure, and unless we find the holygrail on how to deal with them (doubt it), i think we should give people the ability to customize

cgrand21:11:34

one set of settings repl wide won’t cut

cgrand21:11:06

one set of settings per print context (eval, ex, log etc.) is awkward

volrath21:11:03

I'll update the issue I created for settings with this and with the other problem we discussed the other day, about being able to edit settings from aux that also affect user (so that we don't have to ever use unrepl/do in user)

ghadi21:11:17

you need contextual display... but you probably need the same data in the different contexts

ghadi21:11:24

*underlying data

ghadi21:11:04

I have been too lazy to implement this for a while, but translating "Well-Known Signatures" in stacktraces to user-friendly displays. For example, an exception while realizing a lazy seq always contains LazySeq.sval() and LazySeq.seq() adjacently.

ghadi21:11:52

It couple be potentially nice to translate that into something like "Lazy Sequence"

ghadi21:11:02

or "Lazy Sequence Realization"

ghadi21:11:29

There are a lot of landmark function calls in clojure.lang.RT and clojure.lang.* that we could rewrite

cgrand22:11:19

@ghadi I’ve also been thinking about using frequencies of stack frames to drive elision.

cgrand22:11:04

@volrath I’m wondering if setting print limits each time on aux.

volrath08:11:25

@cgrand what do you mean?

cgrand08:11:25

moving the discussion to main thread

cgrand08:11:25

moving the discussion to main thread