libera/#commonlisp - IRC Chatlog
Search
21:19:36
Kingsy
skin: I have looked over this a few times, but it still doesnt really answer my question. for example. I want to return JSON objects not templates. I also want to be able to specify the object that is returned based on the condition that is raised. I don't see how that is done with the items listed here.
21:22:15
Kingsy
the docs are vague. I can see there is a hunchentoot-error class but there is absoutely no information on how it works. What can be overriden and how? etc etc.
21:43:48
Bubblegumdrop
Kingsy if you want to return json you may need to set the content type or something, caveman has this
21:44:08
Bubblegumdrop
https://github.com/fukamachi/caveman/blob/master/v2/skeleton/src/view.lisp#L33
21:44:24
Bubblegumdrop
hunchentoot-error is the base class and you can make your own conditions like so"
21:44:59
Bubblegumdrop
(hunchentoot:define-easy-handler (say-yo :uri "/yo") (name) (setf (hunchentoot:content-type*) "text/plain") (format nil "Hey~@[ ~A~]!" name))
21:46:44
Bubblegumdrop
Kingsy I struggled with the condition system at first too, it's not specific to hunchentoot although hunchentoot may hook into it specifically
21:47:09
Bubblegumdrop
Yeah you were trying to do something like "catch the error and return json if so"
21:47:18
Kingsy
if something goes wrong, in general, it returns an error template for the 500.. I want to change that. so it never returns HTML. ever
21:47:23
Bubblegumdrop
If you're able to explain what you want/are trying to acheive in english it's helpful as well
21:48:21
Kingsy
so lets start with the simple example. I want to. catch ANY error that is thrown during the execution of a route, and return a custom json object, set the content type as you showed. but also log the stack trace to the repl
21:48:45
Kingsy
yeah this is just a learning exercise. I know there are things out there that would make this a lot easier
21:48:47
Bubblegumdrop
mm yeah so you'll have to wrap all that in a progn if you're using your lambda thingy with ,@body
21:49:35
Bubblegumdrop
You should be able to just add (log-whatever ..) in the progn and it should just work
21:51:11
Kingsy
Bubblegumdrop: no I got that working. but it meant it stopped logging to REPL, which didnt help. it meant I didnt know what was going on
21:51:39
Kingsy
it also got me thinking about what happens when it is deployed. we probably want different error handling based on production and not. so I was just looking for general advice.
21:53:05
Bubblegumdrop
Kingsy I actually ended up using Shinmera's VERBOSE library because it's so amazing and versatile. This is what I followed to integrate it into my multithreaded web app: https://www.darkchestnut.com/2021/set-up-verbose-multi-threaded-standalone-applications/
21:54:04
Bubblegumdrop
https://git.lain.church/Bubblegumdrop/cl-deck-builder2/src/branch/master/src/main.lisp#L90
21:55:46
Kingsy
no this is fune, but it doesnt answer the hunchentoot question. I don't know how to properly catch and return different custom objects based on conditions whilst controlling the REPL. the way I am doing it right now feels wrong
21:59:15
Bubblegumdrop
Derived acceptor classes can implement methods for the ACCEPTOR-LOG-MESSAGE and ACCEPTOR-LOG-ACCESS generic functions
21:59:36
Bubblegumdrop
So I think what you'll want to do is have your own acceptor class that subclasses ACCEPETOR: (defclass my-acceptor (hunchentoot:acceptor) ...)
21:59:45
Bubblegumdrop
Then pass that to the thingy instead of the default acceptor or whatever you're using now.
22:00:09
Bubblegumdrop
You'll want to specialize on ACCEPTOR-LOG-MESSAGE and etc for that class like so: (defmethod acceptor-log-message :after ((obj my-acceptor) ..) ..)
22:01:47
Bubblegumdrop
You can do things like open a log file and save it with defparameter or defvar, (defparameter *my-log-file* (open ...))
22:02:23
Bubblegumdrop
I'm not sure if hunchentoot uses threads, but threads make this a whole lot more fun.
22:03:58
Bubblegumdrop
and by that I mean, *standard-output* of your REPL is *not* *standard-output* of the thread hunchentoot is executing on
22:15:32
Kingsy
well I wrote a simple logger and just outputs with format. so I am going to try and use that. will see how it goes.
22:16:40
Bubblegumdrop
https://gitlab.com/myopenbookstore/openbookstore/ I learned a lot from this repository
22:17:06
Bubblegumdrop
https://gitlab.com/myopenbookstore/openbookstore/-/blob/master/run.lisp?ref_type=heads
22:17:37
Bubblegumdrop
https://gitlab.com/myopenbookstore/openbookstore/-/blob/master/src/web/web.lisp?ref_type=heads#L29
22:18:28
Bubblegumdrop
If you find any other programs using hunchentoot I'm interested in knowing more as well. I primarily use woo.
22:18:47
Bubblegumdrop
I'm actually not sure what the differences between clack/lack/hunchentoot/woo/etc are
22:19:03
Bubblegumdrop
like superficially I understand they're different projects with different goals
0:25:06
paulapatience
Shinmera: It is perfectly harmless, but I assume the asterisk is de trop here: https://github.com/Shirakumo/trial/blob/b5e95f859e82faac2db4eb6eba5be26dd1ec80c9/asset.lisp#L48
2:24:26
Bubblegumdrop
paulapatience I'm not certain but I think that's an idiom, like LIST and LIST*
2:25:09
Bubblegumdrop
https://github.com/Shirakumo/trial/blob/b5e95f859e82faac2db4eb6eba5be26dd1ec80c9/asset.lisp#L128
2:45:35
holycow
that video points to a direction in which lisp programmers might look to find full time positions
2:46:03
holycow
it could get interesting, nano tech is coming soon and it will merge with the the LLM stuff happening now
3:07:04
Bubblegumdrop
Clasp is an implementation of Common Lisp primarily designed for compatibility with C++-language programs and libraries.
3:15:53
Bubblegumdrop
Hah, watching this video is a kick. You went from Smalltalk to lisp. I'm doing the opposite! This is so cool. Thanks for all your hard work drmeister_.
3:21:53
holycow
no probs. i don't know what the rules are here but maybe announce it here and on reddit?
3:27:38
hayley
Bubblegumdrop: To misquote Steele, I am now trying to take Lisp programmers halfway to Newspeak.
3:29:51
hayley
Bubblegumdrop: Gilad Bracha in turn took Smalltalk programmers halfway to BETA and E.
3:30:52
Bubblegumdrop
Totally off topic for this channel. I've been studying Smalltalk. Currently looking at GT and Pharo.