lib: adding function to catch exceptions and print them nicely.
lib: updating api version calls to use new static variable