Example #1
0
 /**
  * Format exceptions for return as an objcet and pretty formating in
  * the error log with a complete stack trace
  *
  * @param Resource - Exception resource
  * @param Integer - Custom http response code
  * 
  * @example
  * <code>
  *   try{
  *     throw new Exception("Demo Error Exception");
  *   }catch(\Exception $e){
  *     echo \Rhonda\Error::handle($e);
  *   }
  * </code>
  *
  * @example
  * <code>
  *   try{
  *     throw new Exception("Demo Error Exception");
  *   }catch(\Exception $e){
  *     $error = new \Rhonda\Error();
  *     echo $error->handle($e);
  *   }
  * </code>
  *
  * @example
  * <code>
  *   try{
  *     throw new Exception("Demo Error Exception", 404);
  *   }catch(\Exception $e){
  *     $error = new \Rhonda\Error();
  *     echo $error->handle($e);
  *   }
  * </code>
  *
  * @return Return
  *
  * @since   2014-24-11
  * @author  Deac Karns <*****@*****.**> 
  **/
 public static function handle($e, $status = FALSE)
 {
     if (!$status) {
         $status = 400;
         // Default when no status is given
         if ($e->getCode() != 0) {
             $status = $e->getCode();
         }
     }
     error_log($e->getMessage() . "\n------\n" . $e->getTraceAsString() . "\n------\n");
     http_response_code($status);
     self::add_summary_item(array("code" => $status, "message" => $e->getMessage()));
     return json_encode(\Rhonda\Response::package("", $status));
 }
Example #2
0
<h3>\Rhonda\Response</h3>

<?php 
$data = "Will we have success";
\Rhonda\Error::add_summary_item("We show an error");
echo "<pre>";
print_r(\Rhonda\Response::package($data));
echo "</pre>";