Ring Documentation Walkthrough #14 final – Eval, Error handling

Here you’re in the final chapter in the tutorial.

This is very easy chapter to understand.

We’ll learn first Try/Catch/Done:

try
see x = 5
catch
see 'error' + nl + cCatchError #we use this variable to get the error message
Done

Eval:

eval('x = 5')
see x #output: 5
eval('x = 1*3')
see x #output: 3
eval("func printme see 'print me please.'")
printme()

Raise:

We can use this to raise an exception.

raise('error: blah blah has just happened right now in the front of your eyes.')

Assert:

Official example : here
We can use the Assert() function to test conditions before executing the code,
If the test fail the program will be terminated with an error message contains the assert condition.

x = 10

assert (x = 10) #will pass the test
assert (x = 5) #won't pass the test, output: Line 3 Assertion Failed!

This is the end of this tutorial, of course it’s not the end of the official document, there’s more advanced stuff there, but i don’t want to continue through the rest of the document just like that, i need to parctice more on using the Ring first.

I will make new tutorials after a while.

Till that, i will be posting some ring codes, news, tools & add-ons and other stuff in the blog.

See you in the next post 🙂

amrESSAM.

Advertisements
Ring Documentation Walkthrough #14 final – Eval, Error handling

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s