Ina*_*thi 3 error-handling warnings common-lisp
有没有办法收集警告,但仍然执行它们所属的代码?
我的第一个想法是用来handler-case
抓住所有条件并继续警告,但SimpleWarning
在SBCL似乎没有continue
重启.
CL-USER> (handler-case (warn "Nope") (t (c) c))
#<SIMPLE-WARNING "Nope" {1008080D53}>
CL-USER> (compute-restarts (handler-case (warn "Nope") (t (c) c)))
(#<RESTART SWANK::RETRY {10080867F3}> #<RESTART ABORT {1004710323}>
#<RESTART ABORT {1004710073}>)
CL-USER>
Run Code Online (Sandbox Code Playgroud)
你需要查找WARN
实际做的事情.默认情况下,它会输出警告.如果要访问条件对象,则需要编写处理程序.刚刚从处理程序返回已经继续.如果要删除打印的警告,请调用MUFFLE-WARNING
处理程序.MUFFLE-WARNing
使用相同名称的重启.
CL-USER 32 > (let ((conditions ))
(handler-bind ((t (lambda (c) (push c conditions))))
(warn "foo")
(warn "bar")
(format t "~%baz"))
conditions)
Warning: foo
Warning: bar
baz
(#<SIMPLE-WARNING 402011C9B3> #<SIMPLE-WARNING 402011C63B>)
Run Code Online (Sandbox Code Playgroud)