luabind::cast_failed doubt

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

luabind::cast_failed doubt

Kristoffer Danielsson
Luabind 0.9.1 (I think :P)
Why can't I retrieve error message from lua stack when cast_failed is thrown?!
 
try
{
    retVal = luabind::call_function<string>(m_pLuaState, "foo");
}
catch(luabind::cast_failed &e)
{
    stringstream ss;
    luabind::object error_msg(luabind::from_stack(e.state(), -1));
    ss << error_msg;
   
    cout << ss.str() << endl; // EMPTY STRING!
}
 
Seems like a flaw!

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: luabind::cast_failed doubt

Jonathan Capps

On Feb 14, 2011, at 7:32, Kristoffer Danielsson <[hidden email]
 > wrote:

> Luabind 0.9.1 (I think :P)
> Why can't I retrieve error message from lua stack when cast_failed  
> is thrown?!

Because it's not a lua error. What's happening is that the lua  
function yuo're calling either isn't returning a value, or luabind  
doesn't know how to cast the return value to whatever type you're  
asking for. (There is a more technical explanation, but I'm not  
conversant enough with luabind to give it.)

If you post the relevant  lua function and the section of your C++  
code that calls it, you may get some help fixing the type mismatch.

Jon


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: luabind::cast_failed doubt

Kristoffer Danielsson
I got it working by calling e.what() instead of reading Lua stack.
 
Thanks for the explanation!
 
> From: [hidden email]

> To: [hidden email]
> Date: Mon, 14 Feb 2011 19:29:10 -0500
> Subject: Re: [luabind] luabind::cast_failed doubt
>
>
> On Feb 14, 2011, at 7:32, Kristoffer Danielsson <[hidden email]
> > wrote:
>
> > Luabind 0.9.1 (I think :P)
> > Why can't I retrieve error message from lua stack when cast_failed
> > is thrown?!
>
> Because it's not a lua error. What's happening is that the lua
> function yuo're calling either isn't returning a value, or luabind
> doesn't know how to cast the return value to whatever type you're
> asking for. (There is a more technical explanation, but I'm not
> conversant enough with luabind to give it.)
>
> If you post the relevant lua function and the section of your C++
> code that calls it, you may get some help fixing the type mismatch.
>
> Jon
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user