[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: assert message linefeed
- From: Edgar Toernig <froese@...>
- Date: Sat, 14 Apr 2001 00:15:43 +0200
John Belmonte wrote:
> I'd like to suggest that assert add a linefeed to the message string for us.
> In the case of disabled traceback, lack of a linefeed leaves a "hanging"
> command line. Try running this as a script:
> _ERRORMESSAGE = _ALERT
> assert(nil, "oh boy")
IMHO your assumption that _ALERT is a suitable _ERRORMESSAGE function is
wrong. All error msgs (including assert msgs) have no trailing '\n'.
Try issuing a normal error("foo") - it will be printed _wrong_, too.
The msgs passed to _ERRORMESSAGE are not lines but information strings.
And _ERRORMESSAGE's job is to build nice looking error messages from them.
By setting it to _ALERT your definition of _nice_ is: "just print it with-
out any reformatting" ;-)
If you want it nicer, i.e. make it a single line, use this:
Or if you only want a special behavior for assert (i.e. no traceback)
function assert(cond, msg)
if not cond then
_ALERT("assertion failed! "..(msg or "").."\n")
error() -- will not call _ERRORMESSAGE