/** * Converts an exception into a PHP error. * * This method can be used to convert exceptions inside of methods like `__toString()` * to PHP errors because exceptions cannot be thrown inside of them. * @param \Exception $exception the exception to convert to a PHP error. */ public static function convert_to_error($exception) { trigger_error(Exception::text($exception), E_USER_ERROR); }
/** * Magic object-to-string method. * * echo $exception; * * @uses Exception::text * @return string */ public function __toString() { return Exception::text($this); }
/** * Render the current image. * * echo $image; * * [!!] The output of this function is binary and must be rendered with the * appropriate Content-Type header or it will not be displayed correctly! * * @return string */ public function __toString() { try { // Render the current image return $this->render(); } catch (Exception $e) { if (is_object(Kohana::$log)) { // Get the text of the exception $error = Exception::text($e); // Add this exception to the log Kohana::$log->add(Log::ERROR, $error); } // Showing any kind of error will be "inside" image data return ''; } }