I wrote a macro so a bad line in a hosts file gets logged and the load carries on. This is the whole thing:
(defmacro with-lenient-parse ((&key (log t)) &body body)
`(handler-bind ((missing-field
(lambda (c)
(when ,log
(format *error-output* "skipping: ~A~%" c))
nil))
(bad-port
(lambda (c)
(when ,log
(format *error-output* "warn: ~A~%" c))
nil)))
,@body))
parse-line has a skip-line restart, but I'm not sure anything ever invokes it. The input is name addr [port], one host per line, and I run it with sh run.sh.
With web-02 (no addr) in the file, I get skipping: line 2: missing addr on stderr. Then SBCL drops into the debugger with that same missing-field error and the script dies. I figured returning from the handler would make parse-line return nil for that line, right? Apparently not.
I deleted the web-02 line to get past it. Now I get warn: line 4: bad port abc, and then a type error in privileged-p saying NIL is not of type NUMBER. That function has nothing to do with parsing. The port condition is a plain signal of a warning subclass, and nothing I wrote treats it as fatal.
Is this two bugs or one misunderstanding of how the handler hooks in? What is the macro actually promising the caller? I'm going from memory of the transcript, so I can't paste the full backtrace.