Error Handling in Monkey
Monkey Forums/Monkey Programming/Error Handling in Monkey
| ||
I haven't seen any Try/Catch or equivalent thing, so i guess this has to be done kind of manually so.. How would yo do error handling in Monkey? |
| ||
local image:Image = LoadImage(blah,blah) If image = Null then GoBerserk() Amonst other object relate guff Dabz |
| ||
Diddy has a simple assertion module you could use. http://code.google.com/p/diddy/ Local image:Image = LoadImage(blah,blah) AssertNotNull(image, "Couldn't load the image!") This says "image isn't allowed to be null. If it is, please throw this error message." Basically you give it the condition you expect to pass, and if it fails it will call Error for you. There are lots of other assertion methods for checking equality, booleans, and number ranges. Be aware that if you do any string concatenation or method calls for the message, they will be always be executed even if the assertion passes. |
| ||
Cool! Seems like Diddy is an usefull lib... will play with it, thanks :) |