From e8b216709f1dc57bf65b1c09bf6496b5d8324174 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 20 Oct 2009 22:49:39 +0000 Subject: [PATCH] MDL-12886 finally proper exception handling for Zend servers outside of the function execution --- webservice/lib.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/webservice/lib.php b/webservice/lib.php index 9e8ac4d08c..2a05351ae1 100644 --- a/webservice/lib.php +++ b/webservice/lib.php @@ -33,7 +33,7 @@ class webservice_access_exception extends moodle_exception { * Constructor */ function __construct($debuginfo) { - parent::__construct('accessexception', 'exception', '', null, $debuginfo); + parent::__construct('accessexception', 'webservice', '', null, $debuginfo); } } @@ -110,23 +110,20 @@ abstract class webservice_zend_server implements webservice_server { // that need longer time to finish external_api::set_timeout(); + // now create the instance of zend server + $this->init_zend_server(); + // set up exception handler first, we want to sent them back in correct format that // the other system understands // we do not need to call the original default handler because this ws handler does everything set_exception_handler(array($this, 'exception_handler')); - // now create the instance of zend server - $this->init_zend_server(); - // this sets up $USER and $SESSION and context restrictions $this->authenticate_user(); // make a list of all functions user is allowed to excecute $this->init_service_class(); - // TODO: solve debugging level somehow - Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception'); - // start the server $this->zend_server->setClass($this->service_class); $response = $this->zend_server->handle(); @@ -320,17 +317,9 @@ class '.$classname.' { //TODO: set up some server options and debugging too - maybe a new method //TODO: add some zend exeption handler too $this->zend_server = new $this->zend_class(); - } - /** - * Send the error information to the WS client. - * @param exception $ex - * @return void - */ - protected function send_error($ex=null) { - var_dump($ex); - die('TODO'); - // TODO: find some way to send the error back through the Zend + // TODO: solve debugging level somehow + Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception'); } /** @@ -413,7 +402,7 @@ class '.$classname.' { } // now let the plugin send the exception to client - $this->send_error($ex); + echo $this->zend_server->fault($ex); // some hacks might need a cleanup hook $this->session_cleanup($ex); -- 2.39.5