6.11. Debugging

6.11.1 Error or exception trace

If an error happens when calling an URL, and the option debug was set to True in the configuration file, a trace is displayed in the browser

The information provided consists of :

  • the url called
  • a table showing the script where the error happened : it may not be the script whose name matches the url, in case the error occured in a script included with the Include() function. If so, the arborescence of inclusions is shown. The table shows the script name, the exception name, the line number and the line text in the erroneous script
  • the raw Python traceback
  • a button "Debug" if the user is logged in as administrator
For instance :

Error in /demo/tour/scriptError.py
Line 2
print blah
NameError: name 'blah' is not defined
Traceback (most recent call last):
  File "/home.41/k/a/r/karrigel/www/core/HTTP.py", line 277, in process_request
    target.run(ns)
  File "/home.41/k/a/r/karrigel/www/core/k_target.py", line 351, in run
    exec (self.py_code,namespace)
  File "", line 2, in ?
NameError: name 'blah' is not defined
Clicking on the "Debug" button opens an online editor to update the script where the exception was found

6.11.2 Using SCRIPT_END

When debugging a script it can be useful to use the built-in exception SCRIPT_END to stop the execution. If you want to know the value of a variable when an exception is raised you will write something like

(...)
print "the_value is",the_value
raise SCRIPT_END
(... the line where the exception is raised ...)