Runtime Revolution
 
Articles Other News

RevOnRockets - Part 2

by Andre Garzia


Introducing RocketsDebug, the Web Developer's Best Friend

In the last newsletter we covered building your very first "Hello World" CGI application.

Now, imagine that building a complete, useful web application will require thousands of lines of code. If you have a bug in it, how can you debug it? If you're running on RevHTTP it's fairly easy since the IDE will break on errors and show you useful things but sometimes, you want more. RocketsDebug (previously known as EasyDebug) helps you to debug both local and remote scripts. It works like this: if there's an error during the execution of the CGI, it will trap it and generate a useful report highlighting where the error is (or near where it thinks it is, sometimes this is tricky).

As an example, pick the previous "helloWeb.cgi" you created and make it like this:

#!revolution -ui

global gDataA

on startup
start using "RocketsCGI.rev"
start using "RocketsDebug.rev"

try

get the name of stack "I don't exist"

cgiOutput "Hello Web from Runtime Revolution", "text/plain"

catch n
cgiError n
end try

end startup

You'll see that I put "RocketsDebug.rev" into use and enclosed all the code inside a try/catch block. This is needed for "RocketsDebug" to be able to catch the error. The cgiError function is invoked if the try/catch block fails, this function generates a useful report. If you access http://localhost:8082/cgi-bin/helloWeb.cgi now, you'll see the report and you'll see the cascading error reports flagging the troublesome line in red. In our case, we're trying to access the name of a stack that is not there!

Click the image for a larger version.

If you remove the line 'get the name of stack "I don't exist"', you'll see that the above URL starts working again. Very simple. When you're happy with your web application and ready to deploy it to the general public, you can remove the cgiError call and thus prevent people seeing your code (I plan to add email reports soon).

That's it - short, simple, but very very powerful. Next time we will move to a more fun experiment, and create an online slideshow.

 
©2008 Runtime Revolution Ltd, 15-19 York Place, Edinburgh, Scotland, UK, EH1 3EB.
Questions? Email info@runrev.com for answers.