当前位置: 首页>>代码示例>>PHP>>正文


PHP Kohana::exception_text方法代码示例

本文整理汇总了PHP中Kohana::exception_text方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::exception_text方法的具体用法?PHP Kohana::exception_text怎么用?PHP Kohana::exception_text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kohana的用法示例。


在下文中一共展示了Kohana::exception_text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: write

 public function write(array $messages)
 {
     foreach ($messages as $key => $message) {
         if (is_object($message['body']) && $message['body'] instanceof Exception) {
             $messages[$key]['body'] = Kohana::exception_text($message['body']);
         }
     }
     parent::write($messages);
 }
开发者ID:Burgestrand,项目名称:kohana,代码行数:9,代码来源:file.php

示例2: __toString

 /**
  * Return the SQL query string.
  *
  * @return  string
  */
 public final function __toString()
 {
     try {
         // Return the SQL string
         return $this->compile(Database::instance());
     } catch (Exception $e) {
         return Kohana::exception_text($e);
     }
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:14,代码来源:query.php

示例3: _get

 /**
  * Get from GeoNames by geonameId
  *
  * @static
  * @param   integer  $id
  * @return  array
  */
 private static function _get($id, $lang = 'en')
 {
     $url = Kohana::config('geo.base_url') . '/get?geonameId=' . (int) $id . '&lang=' . $lang . '&style=full';
     try {
         $xml = new SimpleXMLElement($url, null, true);
         Kohana::$log->add(Kohana::DEBUG, 'GeoNames OK: ' . $url);
         return $xml;
     } catch (Exception $e) {
         Kohana::$log->add(Kohana::ERROR, 'GeoNames failed: ' . $url . ' - ' . Kohana::exception_text($e));
         return false;
     }
 }
开发者ID:netbiel,项目名称:core,代码行数:19,代码来源:geo.php

示例4: __toString

 /**
  * Magic object-to-string method.
  *
  *     echo $exception;
  *
  * @uses    Kohana::exception_text
  * @return  string
  */
 public function __toString()
 {
     return Kohana::exception_text($this);
 }
开发者ID:halkeye,项目名称:tops,代码行数:12,代码来源:exception.php

示例5: exception_handler

 /**
  * Inline exception handler, displays the error message, source of the
  * exception, and the stack trace of the error.
  *
  * @uses    Kohana::$php_errors
  * @uses    Kohana::exception_text()
  * @param   object   exception object
  * @return  boolean
  */
 public static function exception_handler(Exception $e)
 {
     try {
         // Get the exception information
         $type = get_class($e);
         $code = $e->getCode();
         $message = $e->getMessage();
         $file = $e->getFile();
         $line = $e->getLine();
         // Create a text version of the exception
         $error = self::exception_text($e);
         if (is_object(self::$log)) {
             // Add this exception to the log
             self::$log->add(Kohana::ERROR, $error);
         }
         if (Kohana::$is_cli) {
             // Just display the text of the exception
             echo "\n{$error}\n";
             return TRUE;
         }
         // Get the exception backtrace
         $trace = $e->getTrace();
         if ($e instanceof ErrorException) {
             if (isset(self::$php_errors[$code])) {
                 // Use the human-readable error name
                 $code = self::$php_errors[$code];
             }
             if (version_compare(PHP_VERSION, '5.3', '<')) {
                 // Workaround for a bug in ErrorException::getTrace() that exists in
                 // all PHP 5.2 versions. @see http://bugs.php.net/bug.php?id=45895
                 for ($i = count($trace) - 1; $i > 0; --$i) {
                     if (isset($trace[$i - 1]['args'])) {
                         // Re-position the args
                         $trace[$i]['args'] = $trace[$i - 1]['args'];
                         // Remove the args
                         unset($trace[$i - 1]['args']);
                     }
                 }
             }
         }
         if (!headers_sent()) {
             // Make sure the proper content type is sent with a 500 status
             header('Content-Type: text/html; charset=' . Kohana::$charset, TRUE, 500);
         }
         // Start an output buffer
         ob_start();
         // Include the exception HTML
         include self::find_file('views', 'kohana/error');
         // Display the contents of the output buffer
         echo ob_get_clean();
         return TRUE;
     } catch (Exception $e) {
         // Clean the output buffer if one exists
         ob_get_level() and ob_clean();
         // Display the exception text
         echo Kohana::exception_text($e), "\n";
         // Exit with an error status
         exit(1);
     }
 }
开发者ID:ascseb,项目名称:core,代码行数:69,代码来源:core.php

示例6: __toString

 /**
  * 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 = Kohana::exception_text($e);
             // Add this exception to the log
             Kohana::$log->add(Kohana::ERROR, $error);
         }
         // Showing any kind of error will be "inside" image data
         return '';
     }
 }
开发者ID:trie0856,项目名称:sidemik,代码行数:26,代码来源:image.php

示例7: catch

 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('forum' => MODPATH . 'forum', 'message' => MODPATH . 'message', 'facebook' => MODPATH . 'facebook', 'modulargaming' => MODPATH . 'modulargaming', 'event' => MODPATH . 'event', 'jelly' => MODPATH . 'jelly', 'sprig' => MODPATH . 'sprig', 'database' => MODPATH . 'database', 'a1' => MODPATH . 'A1', 'a2' => MODPATH . 'A2', 'acl' => MODPATH . 'ACL', 'pagination' => MODPATH . 'pagination', 'captcha' => MODPATH . 'captcha', 'image' => MODPATH . 'image'));
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))')->defaults(array('directory' => 'admin', 'controller' => 'welcome', 'action' => 'index'));
Route::set('shop', 'shop(/<shop>(/<action>(/<item>)))')->defaults(array('controller' => 'shop', 'action' => 'index'));
Route::set('npc', 'npc(/<npc>(/<action>(/<method>)))')->defaults(array('controller' => 'npc', 'action' => 'index'));
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'welcome', 'action' => 'index'));
/**
 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
 * If no source is specified, the URI will be automatically detected.
 */
$request = Request::instance();
try {
    // Attempt to execute the response
    $request->execute();
} catch (Exception $e) {
    if (!IN_PRODUCTION) {
        throw $e;
    }
    // Log the error
    Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e));
    $request = Request::factory('errors/404')->execute();
}
/**
* Display the request response.
*/
echo $request->send_headers()->response;
开发者ID:joffuk,项目名称:modulargaming,代码行数:31,代码来源:bootstrap.php

示例8: test_exception_text

 /**
  * Tests Kohana::exception_text()
  *
  * @test
  * @dataProvider provider_exception_text
  * @covers Kohana::exception_text
  * @param object $exception exception to test
  * @param string $expected  expected output
  */
 public function test_exception_text($exception, $expected)
 {
     $this->assertEquals($expected, Kohana::exception_text($exception));
 }
开发者ID:Tidwell,项目名称:HMXSongs-PHP-API,代码行数:13,代码来源:CoreTest.php

示例9: write

 /**
  * Sets the last_active timestamp and saves the session.
  *
  *     $session->write();
  *
  * [!!] Any errors that occur during session writing will be logged,
  * but not displayed, because sessions are written after output has
  * been sent.
  *
  * @return  boolean
  * @uses    Kohana::$log
  */
 public function write()
 {
     if (headers_sent() or $this->_destroyed) {
         // Session cannot be written when the headers are sent or when
         // the session has been destroyed
         return FALSE;
     }
     // Set the last active timestamp
     $this->_data['last_active'] = time();
     try {
         return $this->_write();
     } catch (Exception $e) {
         // Log & ignore all errors when a write fails
         Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e))->write();
         return FALSE;
     }
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:29,代码来源:session.php

示例10: foreach

<h1>Message Dump</h1>

<?php 
foreach ($messages as $path => $name) {
    echo "<h3>{$path}</h3>";
    try {
        echo Debug::dump(Kohana::message($name));
    } catch (exception $e) {
        echo "Something went terribly wrong. Error message: " . Kohana::exception_text($e);
    }
}
开发者ID:ametsuramet,项目名称:belajar_kohana,代码行数:11,代码来源:message.php

示例11: send_file


//.........这里部分代码省略.........
  * @param   string   filename with path, or TRUE for the current response
  * @param   string   downloaded file name
  * @param   array    additional options
  * @return  void
  * @throws  Kohana_Exception
  * @uses    File::mime_by_ext
  * @uses    File::mime
  * @uses    Request::send_headers
  */
 public function send_file($filename, $download = NULL, array $options = NULL)
 {
     if (!empty($options['mime_type'])) {
         // The mime-type has been manually set
         $mime = $options['mime_type'];
     }
     if ($filename === TRUE) {
         if (empty($download)) {
             throw new Kohana_Exception('Download name must be provided for streaming files');
         }
         // Temporary files will automatically be deleted
         $options['delete'] = FALSE;
         if (!isset($mime)) {
             // Guess the mime using the file extension
             $mime = File::mime_by_ext(strtolower(pathinfo($download, PATHINFO_EXTENSION)));
         }
         // Get the content size
         $size = strlen($this->response);
         // Create a temporary file to hold the current response
         $file = tmpfile();
         // Write the current response into the file
         fwrite($file, $this->response);
         // Prepare the file for reading
         fseek($file, 0);
     } else {
         // Get the complete file path
         $filename = realpath($filename);
         if (empty($download)) {
             // Use the file name as the download file name
             $download = pathinfo($filename, PATHINFO_BASENAME);
         }
         // Get the file size
         $size = filesize($filename);
         if (!isset($mime)) {
             // Get the mime type
             $mime = File::mime($filename);
         }
         // Open the file for reading
         $file = fopen($filename, 'rb');
     }
     // Inline or download?
     $disposition = empty($options['inline']) ? 'attachment' : 'inline';
     // Set the headers for a download
     $this->headers['Content-Disposition'] = $disposition . '; filename="' . $download . '"';
     $this->headers['Content-Type'] = $mime;
     $this->headers['Content-Length'] = $size;
     if (!empty($options['resumable'])) {
         // @todo: ranged download processing
     }
     // Send all headers now
     $this->send_headers();
     while (ob_get_level()) {
         // Flush all output buffers
         ob_end_flush();
     }
     // Manually stop execution
     ignore_user_abort(TRUE);
     // Keep the script running forever
     set_time_limit(0);
     // Send data in 16kb blocks
     $block = 1024 * 16;
     while (!feof($file)) {
         if (connection_aborted()) {
             break;
         }
         // Output a block of the file
         echo fread($file, $block);
         // Send the data now
         flush();
     }
     // Close the file
     fclose($file);
     if (!empty($options['delete'])) {
         try {
             // Attempt to remove the file
             unlink($filename);
         } catch (Exception $e) {
             // Create a text version of the exception
             $error = Kohana::exception_text($e);
             if (is_object(Kohana::$log)) {
                 // Add this exception to the log
                 Kohana::$log->add(Kohana::ERROR, $error);
                 // Make sure the logs are written
                 Kohana::$log->write();
             }
             // Do NOT display the exception, it will corrupt the output!
         }
     }
     // Stop execution
     exit;
 }
开发者ID:halkeye,项目名称:tops,代码行数:101,代码来源:request.php

示例12: send_file


//.........这里部分代码省略.........
			}

			// Range of bytes being sent
			$this->headers['Content-Range'] = 'bytes '.$start.'-'.$end.'/'.$size;
			$this->headers['Accept-Ranges'] = 'bytes';
		}

		// Set the headers for a download
		$this->headers['Content-Disposition'] = $disposition.'; filename="'.$download.'"';
		$this->headers['Content-Type']        = $mime;
		$this->headers['Content-Length']      = ($end - $start) + 1;

		if (Request::user_agent('browser') === 'Internet Explorer')
		{
			// Naturally, IE does not act like a real browser...
			if (Request::$protocol === 'https')
			{
				// http://support.microsoft.com/kb/316431
				$this->headers['Pragma'] = $this->headers['Cache-Control'] = 'public';
			}

			if (version_compare(Request::user_agent('version'), '8.0', '>='))
			{
				// http://ajaxian.com/archives/ie-8-security
				$this->headers['X-Content-Type-Options'] = 'nosniff';
			}
		}

		// Send all headers now
		$this->send_headers();

		while (ob_get_level())
		{
			// Flush all output buffers
			ob_end_flush();
		}

		// Manually stop execution
		ignore_user_abort(TRUE);

		if ( ! Kohana::$safe_mode)
		{
			// Keep the script running forever
			set_time_limit(0);
		}

		// Send data in 16kb blocks
		$block = 1024 * 16;

		fseek($file, $start);

		while ( ! feof($file) AND ($pos = ftell($file)) <= $end)
		{
			if (connection_aborted())
				break;

			if ($pos + $block > $end)
			{
				// Don't read past the buffer.
				$block = $end - $pos + 1;
			}

			// Output a block of the file
			echo fread($file, $block);

			// Send the data now
			flush();
		}

		// Close the file
		fclose($file);

		if ( ! empty($options['delete']))
		{
			try
			{
				// Attempt to remove the file
				unlink($filename);
			}
			catch (Exception $e)
			{
				// Create a text version of the exception
				$error = Kohana::exception_text($e);

				if (is_object(Kohana::$log))
				{
					// Add this exception to the log
					Kohana::$log->add(Kohana::ERROR, $error);

					// Make sure the logs are written
					Kohana::$log->write();
				}

				// Do NOT display the exception, it will corrupt the output!
			}
		}

		// Stop execution
		exit;
	}
开发者ID:nevermlnd,项目名称:cv,代码行数:101,代码来源:request.php

示例13: render

 /**
  * @return string Either an XML document or a gzipped file
  */
 public function render()
 {
     // Default uncompressed
     $response = $this->_xml->saveXML();
     if ($this->gzip) {
         // Try and gzip the file before we send it off.
         try {
             $response = gzencode($response, $this->compression);
         } catch (ErrorException $e) {
             Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e));
         }
     }
     return $response;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:17,代码来源:sitemap.php

示例14: __toString

 public function __toString()
 {
     try {
         return $this->render();
     } catch (Exception $e) {
         return Kohana::exception_text($e);
     }
 }
开发者ID:rlm80,项目名称:Kohana-Batch,代码行数:8,代码来源:batch.php

示例15: foreach

<h1>Config Dump</h1>

<?php 
foreach ($configs as $path => $name) {
    echo "<h3>{$path}</h3>";
    try {
        echo Debug::vars(Kohana::$config->load($name));
    } catch (exception $e) {
        echo "Something went terribly wrong. This is usually caused by\n\t\t      undefined constants because of missing dependancies. Error\n\t\t\t  message: " . Kohana::exception_text($e);
    }
}
开发者ID:seyfer,项目名称:kohana-devtools,代码行数:11,代码来源:config.php


注:本文中的Kohana::exception_text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。