0

For instance, when SBCL says

The value NIL is not of type CONS

I'd like to break execution and invoke the debugger at the point of error.

Right now it is bubbled up all the way to the caller (the Wookie async web server, in my case) where it is simply reported by the default error handler function. Calling (break) in the said function does invoke the debugger, but with Wookie's call stack.

4
  • 2
    Did you already read this? It seems that it might help with your question.
    – Rörd
    May 14, 2014 at 10:16
  • Yep, that does it. Strangely, though, the stack still does not include the frame responsible for the error. The top frame is Wookie's own event handler. It's a start though. Thank you.
    – minya
    May 14, 2014 at 13:40
  • @minya If that link provided a solution that worked for you, you should consider writing up your solution as an answer and marking it as accepted. May 14, 2014 at 14:26
  • Well, I'd say it worked half-way, which I'm ready to accept, but in any case the solution is @Rörd's, is it not?
    – minya
    May 14, 2014 at 17:21

1 Answer 1

1

I may be able to help with your question. There are two possible things going on. One is that you started your event loop with

(with-event-loop (:catch-app-errors t) ...)

This essentially tells cl-async that you want it to catch any errors that are not handled and run the default event handler for them. The default error handler says "is this an actual error? of so call (error event)." This makes it so that your errors appear to be originating from within cl-async's toplevel. The purpose behind this is that you can write your own error handler to catch things as you see fit.

The second thing that may be going on is that you're using cl-async's futures, which also obfuscate errors by wrapping them in their own error handling. This makes async lexical error handling possible via the future-handler-case macro.

So if you're getting an error and you don't know where, do the following:

;; do this *before* loading cl-async-future. this turns off ALL error capturing for
;; futures, letting your errors bubble up to top level without interference
(push :future-debug *features*)

;; ... load cl-async / wookie ...

;; tell cl-async not to catch errors
(cl-async:with-event-loop (:catch-app-errors nil) ...)

Now when you get an error, it should bubble up to the REPL and you'll be able to see exactly where it came from. There are ways (using futures, at least) to get a makeshift backtrace for errors that happen deep within async functions, but that's beyond the scope of the answer and assumes that you're even using futures in the first place (although Wookie does make some use of them).

Hope that helps!

1
  • Thank you for a great explanation; however, if I do that, Wookie signals ERROR condition in the pre-route authentication handler which I modeled after Turtle's (and that's the only place where I'm using futures explicitly). I'm not sure it indicates an actual error rather than I'm not following your instructions to the point... because the handler works properly when I test it over the actual requests.
    – minya
    May 17, 2014 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.