Fork me on GitHub
#babashka-sci-dev
<
2022-09-02
>
Crispin07:09:28

Is there a way of getting better exceptions coming out of my pod?

Crispin07:09:00

When an invoke call raises an exception, it ends up with the wrong line number

Crispin07:09:51

I submit my error raised in the pod call here:

Crispin07:09:36

And running a script that triggers that I get this:

Crispin07:09:21

$ bb test/bb.clj
loading pod...
loaded
:prompt-password "Password for crispin@localhost"
:get-password
:prompt-password "Password for crispin@localhost"
:get-password
:prompt-password "Password for crispin@localhost"
:get-password
:prompt-password "Password for crispin@localhost"
:get-password
:prompt-password "Password for crispin@localhost"
:get-password
:prompt-password "Password for crispin@localhost"
:get-password
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  SSH_MSG_DISCONNECT: 2 Too many authentication failures 
Data:     {:type com.jcraft.jsch.JSchException}
Location: /home/crispin/dev/clojure/bbssh/test/bb.clj:25:3

----- Context ------------------------------------------------------------------
21:                 "bbssh.core"] {:transport :socket})
22: 
23: ;; run pod process from native-image to test
24: #_(pods/load-pod "./bbssh" {:transport :socket})
25: 
      ^--- SSH_MSG_DISCONNECT: 2 Too many authentication failures 
26: (println "loaded")
27: 
28: (require
29:  '[pod.epiccastle.bbssh.user-info :as user-info]
30:  '[pod.epiccastle.bbssh.session :as session]

----- Stack trace --------------------------------------------------------------
babashka.pods.impl/processor         - <built-in>
babashka.pods.sci/load-pod/fn--27349 - <built-in>
pod.epiccastle.bbssh.session/connect - /home/crispin/dev/clojure/bbssh/test/bb.clj:25:3
pod.epiccastle.bbssh.session/connect - /home/crispin/dev/clojure/bbssh/test/bb.clj:21:1
my-project.core                      - /home/crispin/dev/clojure/bbssh/test/bb.clj:61:3

Crispin07:09:52

line 25 is actually blank. It is actually line 61 that is executing when this gets raised.

Crispin08:09:23

some kind of metadata I need to preserve or add, perhaps?

Crispin08:09:17

the stack trace is actually correct. It's just displaying the wrong file

Crispin08:09:07

pod.epiccastle.bbssh.session/connect is not from /home/crispin/dev/clojure/bbssh/test/bb.clj, it is injected into the pod apon describe

Crispin08:09:37

the stack trace line my-project.core is actually the correct line

Crispin08:09:02

maybe if the file associated with pod.epiccastle.bbssh.session was something like the <built-in>. Or it could even refer to the source file within the pod project. That would be pretty sweet.

Crispin08:09:35

Maybe there could be a filename registered with the describe response? Like {"namespace": "pod.epiccastle.bbssh.session", "filename": "<pod:pod/epiccastle/bbssh/session.clj>", "vars": [...]}

borkdude18:09:02

yeah, I'm not sure, haven't thought deeply about pod errors + locations

borkdude18:09:07

it's a bit like calling HTTP APIs. The error probably is reported at the site where you call an HTTP client, not the location of the response in a server that crashed...

borkdude18:09:09

I would at least expect that the location of the client side function that calls the pod would be reported. Isn't that the case?

Crispin01:09:41

If when displaying the code with the traceback you looked for the first frame with a valid filename, and displayed that. ie you skipped any filenames of the format <*>. Then, if the injected describe namespaces had one of those <*> names, they would be skipped, and the file that would be displayed would be the correct one, at the correct line.

Crispin01:09:50

I can have a poke around see what I can do