lua-users home
lua-l archive

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


what if the function (or level) that issued the error is certain that
the error did not happen in its body, but on higher stack levels?

imagine the following situation

function complex(self)
  if not self.a or not self.b then
    error("Must specify self.a and self.b when constructing a complex number",2)
  end
  return { a = self.a, b = self.b }
end

should the line in complex() be included in the stack trace?
it could to inform the user about the location where the error was
issued, not actually where it ocurred...

just my 2 cents..

-- Fred

On Wed, 29 Sep 2004 09:32:02 -0400, Aaron Brown
<aaron-lua@oakadaptive.com> wrote:
> Frederico Rodrigues Abraham wrote:
> 
> > The line where the error happened seems correct. (line 10,
> > the call to p2() in p1 body)
> 
> A human interpreting the code can pick one line where the
> error occurs, but which line that will be depends on the
> context.  As far as Lua is concerned, the error takes place
> just as much on lines 2 and 6 as it does on lines 10, 15,
> and 19.
> 
> In other words, does an error occur on line 2?  Yes, because
> that's where "error" is called.  Does an error occur on line
> 19?  Yes, because that's where a function ("luaf") is called
> that calls a function ("p1") that calls a function ("p2")
> that calls a function ("p3") where "error" is called.
> 
> --
> Aaron
> 
> 



-- 
    -- Fred