Exception Handling - connection.py

July 22, 2013 - 2 minute read -
exception python gsoc

Commits

Things I did

  • Added exceptions in connection.py
    The functions in connection.py interact with the low level GDbus API. It is the API at gi.repository.Gio. Using this API, I am making new connection over dbus and invoking remote methods. Exception handling is done using 'GError'. This exception which occurred is sys.exc_info()[1]. lets say :
    error = sys.exc_info()[1]
    			
    Then the error message is contained in error.message and the domain in error.domain.
    msg = error.message
    domain = error.domain
    			
  • Added properties in connection.py
  • Added unittests based on py.test modules in connection.py. I covered a small chunk of it. Address and bus_name are done.

Problems I faced

The Exception of DBus (GError) are located at the file /usr/lib/python2.7/dist-packages/gi/_glib/option.py and /usr/lib/python2.7/dist-packages/gi/_glib/__init__.py. However, including in my PYTHON_PATH was a problem. Somehow doing this worked

from gi.repository.GLib import GError
	

Some good links I found are:
https://developer.gnome.org/glib/2.34/glib-Error-Reporting.html: Explains the error reporting procedure in C.

What Next..

Writing unittests for connection.py. At present it covers only 5-10% of connection.py

Comments Section

Feel free to comment on the post but keep it clean and on topic.

blog comments powered by Disqus