lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Fri, Oct 17, 2014 at 2:13 PM, Roberto Ierusalimschy <> wrote:
> I have a program with many instances of
>     error(msg)
> where msg is each time some _expression_.
> If this _expression_ evaluates to a non-string,
> the error message is merely
>     lua: (error object is not a string)
> There are obviously plenty of easy workarounds,
> but is there some deep reason why the traceback
> is omitted?

The traceback is not added to the final message (when it is being
printed), but to the error object itself (among other reasons because
the traceback is created before the error is actually raised, while the
stack is still alive). When the error object is not a string, it seems
tricky to append a traceback into it.

-- Roberto

I wanted to add my .02.

I have a similar setup to what Dirk described. In a few cases I had done something wrong, only to have this message appeared. It has quickly become my most dreaded message.

When it happens, I then pepper my code with print statements, in order to track down where it happened within my project.

I don't have a suggestion that would be especially illuminating, but it is frustrating when it happens and due to the nature of errors and the way that I develop software, it's lead me to wrap `error` so that I can trap this case.