Rrrrry123
|
  |
| Joined: 23 Nov 2009 |
| Total Posts: 93 |
|
|
| 28 Dec 2013 05:43 PM |
So, I do some C# programming and to get an error message you just do a
try { //code }
catch (Exception ex) { Console.WriteLine(ex.Message) }
and the console prints the error message.
Can I/How would I do that in Roblox Lua? |
|
|
| Report Abuse |
|
|
jawa280
|
  |
| Joined: 26 Jun 2007 |
| Total Posts: 453 |
|
|
| 28 Dec 2013 07:45 PM |
You can do this using the pcall function
Example:
function test() pprint("Test!") -- The statement that will cause the error end
print(pcall(test)) -- will print either true or false, based on if the call succeeds, if false it will print the error
print(pcall(function() pprint("Test!") end)) -- same thing, just one line
assert(pcall(function() pprint("Test!") end)) -- you can use assert for a more "proper" error message
For more information: http://wiki.roblox.com/index.php/Pcall#pcall http://wiki.roblox.com/index.php/Assert#assert |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2013 07:46 PM |
| That is Lua not C# lol narb |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2013 07:47 PM |
| Oh nvm I didn't read it all. It was too long i sowwy |
|
|
| Report Abuse |
|
|
yoiano2
|
  |
| Joined: 22 Sep 2007 |
| Total Posts: 522 |
|
|
| 28 Dec 2013 07:56 PM |
Since when can't you ask non-lua related questions? You still can can't you? Or am I just that old...
|
|
|
| Report Abuse |
|
|
Rrrrry123
|
  |
| Joined: 23 Nov 2009 |
| Total Posts: 93 |
|
|
| 29 Dec 2013 03:59 PM |
| Thank you very much, jawa280 |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:01 PM |
In rblx.lua you canjust do:
Error(msg) |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:02 PM |
@yoi he was talking to the guy he thought OP wanted C# code but he wanted RBX.Lua code so |
|
|
| Report Abuse |
|
|