Replace pear errors with exceptions

This updates the Loris code to use PHP5 style exceptions, rather than PHP4 style PEAR errors. This should fix a number of cryptic error messages such as "Could not convert object of type PEAR_Error to string" and general make the code more robust, as exceptions don't need to be handled at every level of the stack.