Indigo Rose Software
  #1  
Old 11-16-2004
humdingerx humdingerx is offline
Forum Member
 
Join Date: Nov 2004
Posts: 9
error, pcall, Lua and AMS5

I've been exploring Lua a little and noticed it's error handling throw/catch mechanism using error()/pcall() I've successfully used this in an AMS 5 project I'm not really a great programmer but is there any way to get an error handler of my own implemented and running automatically?

i.e. instead of:
--------------------------------------------------------------------------
function foo()
-- attempt to perform arithmetic on a string causes exception
a = 'a'+1;
-- this bit is not reached!
return "All done!";
end

local status, err = pcall(foo);

Dialog.Message("Result of foo function", err, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

-- execution continues!
--------------------------------------------------------------------------

I was wondering if it's possible to extend/override the default behaviour of pcall somehow so it calls my own error handler function (which I could define elsewhere?) Any ideas/example code much appreciated!

Last edited by humdingerx; 11-16-2004 at 08:56 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 02:59 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software