<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I'm not sure that's the best solution. Running into trouble<br>
while trying to log an error message is always a pain in<br>
the neck, but it's usually not best to just go ahead anyway.<br>
I try to write fallbacks. (Hans, I'm sure you know about<br>
this idea; I'm just saying it might be good in this case.)<br>
<br>
Here's a simple example of what I mean.<br>
<br>
<tt>(defun safe-format (stream control-string &rest
format-arguments)<br>
"This is like FORMAT, except that if a condition is signaled<br>
during the call to FORMAT, it falls back by printing the<br>
FORMAT control string, followed by as many of the arguments<br>
as possible. This function never signals any conditions.<br>
This means that it can hide errors, so it should not be used<br>
widely. It is intended to be used in code that reports<br>
errors and stack traces, and in logging."<br>
(handler-case<br>
(apply #'format stream control-string format-arguments)<br>
(serious-condition ()<br>
(ignore-errors<br>
(flet ((print-fallback (stream)<br>
(princ "Error during format: " stream)<br>
(princ control-string stream)<br>
(dolist (arg format-arguments)<br>
(princ " " stream)<br>
(handler-case<br>
(princ arg stream)<br>
(serious-condition ()<br>
(ignore-errors<br>
(princ "[error printing argument of type "
stream)<br>
(ignore-errors<br>
(princ (type-of arg) stream))<br>
(princ "]" stream)))))))<br>
(if (null stream)<br>
(with-output-to-string (strm)<br>
(print-fallback strm))<br>
(print-fallback stream)))))))<br>
</tt><br>
-- Dan<br>
<br>
<br>
Hans Hübner wrote:
<blockquote
cite="mid:AANLkTilTtN6sG-2Yb1ABl4JyqdvjPf2JzkacYEhPLf3-@mail.gmail.com"
type="cite">
<pre wrap="">On Wed, Jun 16, 2010 at 01:49, Cyrus Harmon <a class="moz-txt-link-rfc2396E" href="mailto:ch-tbnl@bobobeach.com"><ch-tbnl@bobobeach.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">So, while trying to track down an unrelated issue where my handlers aren't getting called anymore, I came across the following issue where failure to open the message log file results in an error, which, in turn, attempts to open the message log file. The problem in this case was that the permissions were bogus for the directory I was trying to open. But, still, we should probably have a nicer error message than "recursive lock attempt" here.
</pre>
</blockquote>
<pre wrap=""><!---->
I agree. Can you supply a patch that corrects the problem? Using a
recursive lock would probably the easiest solution.
Thanks,
Hans
_______________________________________________
tbnl-devel site list
<a class="moz-txt-link-abbreviated" href="mailto:tbnl-devel@common-lisp.net">tbnl-devel@common-lisp.net</a>
<a class="moz-txt-link-freetext" href="http://common-lisp.net/mailman/listinfo/tbnl-devel">http://common-lisp.net/mailman/listinfo/tbnl-devel</a>
</pre>
</blockquote>
</body>
</html>