Esempio n. 1
0
<?php

require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'library/Frapi/AllFiles.php';
set_error_handler(array('Frapi_Error', 'errorHandler'), E_ALL);
$controller = new Frapi_Controller_API();
try {
    $controller->authorize();
    echo $controller->processAction()->processOutput();
} catch (Frapi_Exception $e) {
    echo $controller->processError($e);
    exit;
} catch (Exception $e) {
    echo $controller->processError(new Frapi_Error($e));
    exit;
}
Esempio n. 2
0
File: Api.php Progetto: Rud5G/frapi
 /**
  * Statically Process Frapi Errors
  *
  * This method will process the FRAPI Errors, pass them to the 
  * output handler, and format it correctly. 
  *
  * This method is in fact a hack. Whenever we instantiate the controller
  * object from the source — index.php in this case — we can't try and
  * catch the same controller object because the exception might in fact
  * be thrown directly from within the constructor thus invalidating
  * and sending the self $controller object out of scope. Thence this hack
  * that instantiates it's own controller, ignores the exception thrown
  * 
  * This also allows us to catch syntax errors before the constructor
  * is invoked and allows us to handle the errors gracefully.
  *
  * @param Frapi_Exception $e  The frapi exception to use
  * @return object The response object.
  */
 public static function processInternalError(Frapi_Exception $e)
 {
     try {
         $controller = new Frapi_Controller_API();
     } catch (Exception $e) {
         // This is a hack to intercept anything that may
         // have happened before the internal error collection
         // during the initialisation process.
     }
     return $controller->getOutputInstance($controller->getFormat())->setOutputAction('defaultError')->populateOutput($e->getErrorArray())->sendHeaders($e)->executeOutput();
 }