Install a condition handler in Common Lisp

The Drakma HTTP library on CLISP generates a USOCKET: UNSUPPORTED error due to an error in Drakma + CLISP. However, it turns out that restarting CONTINUE is working fine. So I spent some time with CLtL and other links trying to figure out how to write a reload handler.

(defun http-request (url param) (handler-bind ((USOCKET:UNSUPPORTED #'(lambda (x) (invoke-restart 'continue))))) (drakma:http-request url :method :post :parameters param)) 

According to my best understanding, the above code should catch the USOCKET: UNSUPPORTED error. This is not true; he seems to be ignoring the binder.

How to fix it?

+4
source share
1 answer

Well, I'm not sure if I can help you here, but: Your partners are completely confused. Try this as follows:

 (defun http-request (url param) (handler-bind ((usocket:unsupported #'continue)) (drakma:http-request url :method :post :parameters param))) 

If this does not work, try to check if you are really fulfilling the correct condition, and if the reboots that you expect are really available:

 (defun http-request (url param) (handler-bind ((condition (lambda (c) (print c) (print (compute-restarts))))) (drakma:http-request url :method :post :parameters param))) 

Alternatively you can watch IGNORE-ERRORS

+5
source

Source: https://habr.com/ru/post/1333750/


All Articles