本文整理汇总了PHP中exception::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP exception::getMessage方法的具体用法?PHP exception::getMessage怎么用?PHP exception::getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exception
的用法示例。
在下文中一共展示了exception::getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: panic
public static function panic(\exception $e)
{
$response = Factory::make("response");
$vars = [];
$vars['message'] = $e->getMessage();
$vars['file_line'] = $e->getFile() . " " . $e->getLine();
$response->renderHtml("exception.html", $vars);
}
示例2: errorAction
/**
* Show YAF Error
* only display errors under DEV, else save error in LOG_FILE
* @param exception $exception
* @return void
*/
public function errorAction($exception)
{
switch ($exception->getCode()) {
case YAF_ERR_NOTFOUND_MODULE:
case YAF_ERR_NOTFOUND_CONTROLLER:
case YAF_ERR_NOTFOUND_ACTION:
case YAF_ERR_NOTFOUND_VIEW:
if (ENV == 'DEV') {
echo 404, ":", $exception->getMessage();
} else {
echo 404;
file_put_contents(LOG_FILE, $exception->getMessage() . PHP_EOL, FILE_APPEND);
}
break;
default:
if (ENV == 'DEV') {
echo 0, ":", $exception->getMessage();
} else {
echo 'Unknown error';
file_put_contents(LOG_FILE, $exception->getMessage() . PHP_EOL, FILE_APPEND);
}
break;
}
}
示例3: header
/**
* Static s_display_error
*/
static function generic_display_error(exception $ex)
{
$title = $ex->getMessage();
$err_no = $ex->getCode();
if (!class_exists('loader') || class_exists('loader') && !loader::in_ajax()) {
header('', true, 500);
$message = '<style>* {font: 0.97em verdana;} a {text-decoration:none;background:#EFEFEF;padding:4px;} a:hover{background: red;}</style><h1>Ups! We have an error here.</h1>';
$subject = "Error " . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$message .= 'Visit <a href="/">index</a> page.<br/><br/>';
echo $message;
// if debug
if (class_exists('core') && core::is_debug()) {
echo '<br/>Error : ' . $title . ' : ' . $err_no;
echo '<br/><br/>' . nl2br($ex->getTraceAsString());
}
}
}
示例4: exceptionHandler
/**
* Custom exception handler with backtrace
*
* @param exception $exception Thrown exception
*
* @return void
*/
function exceptionHandler($exception)
{
global $dPconfig;
$time = date("Y-m-d H:i:s");
// User information
$user_id = null;
$user_view = "";
if (class_exists("CAppUI", false) && CAppUI::$user) {
$user = CAppUI::$user;
if ($user->_id) {
$user_id = $user->_id;
$user_view = $user->_view;
}
}
// Server IP
$server_ip = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : null;
$file = mbRelativePath($exception->getFile());
$line = $exception->getLine();
$type = "exception";
$text = $exception->getMessage();
// Stacktrace
$contexts = $exception->getTrace();
foreach ($contexts as &$ctx) {
unset($ctx['args']);
}
// Might noy be ready at the time error is thrown
$session = isset($_SESSION) ? $_SESSION : array();
unset($session['AppUI']);
unset($session['dPcompteRendu']['templateManager']);
$_all_params = array("GET" => $_GET, "POST" => $_POST, "SESSION" => $session);
filterInput($_all_params);
// CApp might not be ready yet as of early error handling
$request_uid = null;
if (class_exists("CApp", false)) {
$request_uid = CApp::getRequestUID();
CApp::$performance[CError::$_categories["exception"]]++;
}
$build_output = ini_get("display_errors");
$save_to_file = false;
$data = array("stacktrace" => $contexts, "param_GET" => $_all_params["GET"], "param_POST" => $_all_params["POST"], "session_data" => $_all_params["SESSION"]);
if (@$dPconfig["error_logs_in_db"] && class_exists("CErrorLog")) {
try {
CErrorLog::insert($user_id, $server_ip, $time, $request_uid, $type, $text, $file, $line, $data);
} catch (Exception $e) {
$build_output = true;
$save_to_file = true;
}
} else {
$build_output = true;
$save_to_file = true;
}
if ($build_output) {
$hash = md5(serialize($contexts));
$html_class = "big-warning";
$log = "\n\n<div class='{$html_class}' title='{$hash}'>";
if ($user_id) {
$log .= "\n<strong>User: </strong>{$user_view} ({$user_id})";
}
$file = CError::openInIDE($file, $line);
$log .= <<<HTML
<strong>Time: </strong>{$time}
<strong>Type: </strong>{$type}
<strong>Text: </strong>{$text}
<strong>File: </strong>{$file}
<strong>Line: </strong>{$line}
HTML;
foreach ($_all_params as $_type => $_params) {
$log .= print_infos($_all_params[$_type], $_type);
}
foreach ($contexts as $context) {
$function = isset($context["class"]) ? $context["class"] . ":" : "";
$function .= $context["function"] . "()";
$log .= "\n<strong>Function: </strong> {$function}";
if (isset($context["file"])) {
$log .= "\n<strong>File: </strong>" . CError::openInIDE($context["file"], isset($context["line"]) ? $context["line"] : null);
}
if (isset($context["line"])) {
$log .= "\n<strong>Line: </strong>" . $context["line"];
}
$log .= "<br />";
}
$log .= "</div>";
if ($save_to_file) {
file_put_contents(LOG_PATH, $log, FILE_APPEND);
}
if (ini_get("display_errors")) {
echo $log;
}
}
}
示例5: log
/**
* Virhelogi
*
* @param string $message Virheviesti
* @param exception $exception Exception
* @param string $type Kirjataanko tuote vai tilauslogiin
*/
public function log($message, $exception = '', $type = 'product')
{
if (self::LOGGING == true) {
$timestamp = date('d.m.y H:i:s');
$message = utf8_encode($message);
if ($exception != '') {
$message .= " (" . $exception->getMessage() . ") faultcode: " . $exception->faultcode;
}
$message .= "\n";
$log_location = $type == 'product' ? '/tmp/magento_log.txt' : '/tmp/magento_order_log.txt';
error_log("{$timestamp}: {$message}", 3, $log_location);
}
}
示例6: showError
/**
* Sends an errormessage (html) to the user
*
* @access public
* @static
* @param exception $exception Instanz of an exception
*/
public function showError($exception)
{
/* flush cache */
ob_clean();
ob_start();
/* display html */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>phpMedaDB :: Exception</title>
<style type="text/css">
<!--
body { font-size:12px; font-family:monospace; }
h1 { font-size:18px; color:red; }
.phpmediadb-body-exception { background-color:#FFFFCC; border:1px dashed grey; margin-bottom:10px; padding:5px; }
.phpmediadb-body-exception-code { background-color:#FAFAFA; border:1px dotted grey; margin:10px; padding:5px; }
.phpmediadb-body-exception-copyright { text-align:right; }
-->
</style>
</head>
<body>
<div class="phpmediadb-body-exception">
<h1>Ouch, got an exception...</h1>
Sorry but I was not able to complete your request. Please try again.
<?php
if (constant('PHPMEDIADB_SYSTEM_DEBUGLEVEL') >= 1) {
?>
<br /><br />
<b>Exception Details:</b>
<div class="phpmediadb-body-exception-code"><pre><?php
echo htmlentities($exception->getMessage());
?>
</pre></div>
<?php
}
?>
</div>
<?php
if (constant('PHPMEDIADB_SYSTEM_DEBUGLEVEL') >= 2) {
?>
<div class="phpmediadb-body-exception">
<h1>Debug</h1>
<b>Stack trace:</b><br />
<div class="phpmediadb-body-exception-code"><pre><?php
echo htmlentities($exception->getTraceAsString());
?>
</pre></div>
<br />
<b>File:</b> <?php
echo htmlentities($exception->getFile());
?>
<b>Line:</b> <?php
echo htmlentities($exception->getLine());
?>
</div>
<?php
}
?>
<div class="phpmediadb-body-exception-copyright">
phpMediaDB :: The media database<br />
Version <?php
echo PHPMEDIADB_SYSTEM_VERSION;
?>
</div>
</body>
</html><?php
}
示例7: handle
/**
* Handles all PHP exceptions.
*
* @param exception|\exception $exception An exception.
*
* @note Exceptions handled successfully by this routine will NOT be logged by PHP as errors.
* As the exception handler, we will need to log and/or display anything that needs to be recorded here.
* The PHP interpreter simply terminates script execution whenever an exception occurs (nothing more).
*
* @note If an exception is thrown while handling an exception; PHP will revert to it's default exception handler.
* This will result in a fatal error that may get logged by PHP itself (depending on `error_reporting` and `error_log`).
*
* @throws exception|\exception If we are unable to handle the exception (i.e. the XDaRk Core is not even available yet),
* this handler will simply re-throw the exception (forcing a fatal error); as just described in the previous note.
*
* @note The display of exception messages is NOT dependent upon `display_errors`; nor do we consider that setting here.
* However, we do tighten security within the `exception.php` template file; hiding most details by default; and displaying all details
* only if the current user is a Super Administrator in WordPress; or if `WP_DEBUG_DISPLAY` mode has been enabled on this site.
*
* @note If there was another exception handler active on the site; and this exception is NOT for
* a plugin under this version of the XDaRk Core; we simply hand the exception back to the previous handler.
* In the case of multiple versions of the XDaRk Core across various plugins; this allows us to work up the chain
* of previous handlers until we find the right version of the XDaRk Core; assuming each version
* of the XDaRk Core handles things this way too (which is to be expected).
*
* @see http://php.net/manual/en/function.set-exception-handler.php
*/
public static function handle(\exception $exception)
{
try {
static::$exception = $exception;
// Reference.
if (static::$exception instanceof exception) {
static::$plugin = static::$exception->plugin;
static::handle_plugin_exception();
return;
// We're done here.
}
// Else this is some other type of exception.
if (static::$previous_handler && is_callable(static::$previous_handler)) {
call_user_func(static::$previous_handler, static::$exception);
return;
// We're done here.
}
// There is NO other handler available (deal w/ it here; if possible).
if (is_callable('\\' . stub::$core_ns . '\\core')) {
static::$plugin = core();
static::handle_plugin_exception();
return;
// We're done here.
}
throw static::$exception;
// Re-throw (forcing a fatal error).
} catch (\exception $_exception) {
throw new \exception(sprintf(stub::__('Failed to handle exception code: `%1$s` with message: `%2$s`.'), $exception->getCode(), $exception->getMessage()) . ' ' . sprintf(stub::__('Failure caused by exception code: `%1$s` with message: `%2$s`.'), $_exception->getCode(), $_exception->getMessage()), 20, $_exception);
}
}
示例8: send_error
/**
* Send the error information to the WS client
* formatted as an XML document.
*
* @param exception $ex the exception to send back
*/
protected function send_error($ex = null)
{
if ($ex) {
$info = $ex->getMessage();
if (debugging() and isset($ex->debuginfo)) {
$info .= ' - ' . $ex->debuginfo;
}
} else {
$info = 'Unknown error';
}
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><SOAP-ENV:Fault>
<faultcode>MOODLE:error</faultcode>
<faultstring>' . $info . '</faultstring>
</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>';
$this->send_headers();
header('Content-Type: application/xml; charset=utf-8');
header('Content-Disposition: inline; filename="response.xml"');
echo $xml;
}
示例9: get_exception_info
/**
* Returns detailed information about specified exception.
* @param exception $ex
* @return object
*/
function get_exception_info($ex) {
global $CFG, $DB, $SESSION;
if ($ex instanceof moodle_exception) {
$errorcode = $ex->errorcode;
$module = $ex->module;
$a = $ex->a;
$link = $ex->link;
$debuginfo = $ex->debuginfo;
} else {
$errorcode = 'generalexceptionmessage';
$module = 'error';
$a = $ex->getMessage();
$link = '';
$debuginfo = null;
}
$backtrace = $ex->getTrace();
$place = array('file'=>$ex->getFile(), 'line'=>$ex->getLine(), 'exception'=>get_class($ex));
array_unshift($backtrace, $place);
// Be careful, no guarantee moodlelib.php is loaded.
if (empty($module) || $module == 'moodle' || $module == 'core') {
$module = 'error';
}
if (function_exists('get_string_manager')) {
if (get_string_manager()->string_exists($errorcode, $module)) {
$message = get_string($errorcode, $module, $a);
} elseif ($module == 'error' && get_string_manager()->string_exists($errorcode, 'moodle')) {
// Search in moodle file if error specified - needed for backwards compatibility
$message = get_string($errorcode, 'moodle', $a);
} else {
$message = $module . '/' . $errorcode;
}
} else {
$message = $module . '/' . $errorcode;
}
// Be careful, no guarantee weblib.php is loaded.
if (function_exists('clean_text')) {
$message = clean_text($message);
} else {
$message = htmlspecialchars($message);
}
if (!empty($CFG->errordocroot)) {
$errordocroot = $CFG->errordocroot;
} else if (!empty($CFG->docroot)) {
$errordocroot = $CFG->docroot;
} else {
$errordocroot = 'http://docs.moodle.org';
}
if ($module === 'error') {
$modulelink = 'moodle';
} else {
$modulelink = $module;
}
$moreinfourl = $errordocroot . '/en/error/' . $modulelink . '/' . $errorcode;
if (empty($link)) {
if (!empty($SESSION->fromurl)) {
$link = $SESSION->fromurl;
unset($SESSION->fromurl);
} else {
$link = $CFG->wwwroot .'/';
}
}
$info = new stdClass();
$info->message = $message;
$info->errorcode = $errorcode;
$info->backtrace = $backtrace;
$info->link = $link;
$info->moreinfourl = $moreinfourl;
$info->a = $a;
$info->debuginfo = $debuginfo;
return $info;
}
示例10: testRun
public function testRun()
{
$this->given($pusher = new testedClass(__FILE__), $pusher->setTaggerEngine($taggerEngine = new \mock\mageekguy\atoum\scripts\tagger\engine()), $pusher->setGit($git = new \mock\mageekguy\atoum\cli\commands\git()), $pusher->setErrorWriter($errorWriter = new \mock\mageekguy\atoum\writers\std\err()), $pusher->setInfoWriter($infoWriter = new \mock\mageekguy\atoum\writers\std\out()), $this->calling($infoWriter)->write = $infoWriter)->assert('Pusher should write error if tag file is not readable')->if($this->calling($errorWriter)->write = $errorWriter, $this->function->file_get_contents = false)->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments('Unable to read \'' . $pusher->getTagFile() . '\'')->once()->assert('Pusher should write error if tag file is not writable')->if($this->calling($errorWriter)->write = $errorWriter, $this->function->file_put_contents = false, $this->function->file_get_contents = '0.0.0')->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments('Unable to write in \'' . $pusher->getTagFile() . '\'')->once()->assert('Pusher should tag code and commit it if tag file is writable')->if($this->function->file_put_contents = function ($path, $data) {
return strlen($data);
}, $this->calling($taggerEngine)->tagVersion->doesNothing(), $this->calling($git)->addAllAndCommit = $git, $this->calling($git)->checkoutAllFiles = $git, $this->calling($git)->createTag = $git, $this->calling($git)->push = $git, $this->calling($git)->forcePush = $git, $this->calling($git)->pushTag = $git, $this->calling($git)->resetHardTo = $git, $this->calling($git)->deleteLocalTag = $git)->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '0.0.1')->once()->mock($taggerEngine)->call('tagVersion')->before($this->mock($git)->call('addAllAndCommit')->withArguments('Set version to 0.0.1.')->before($this->mock($git)->call('createTag')->withArguments('0.0.1')->before($this->mock($git)->call('push')->withArguments($pusher->getRemote())->once())->before($this->mock($git)->call('pushTag')->withArguments('0.0.1', $pusher->getRemote())->once())->once())->once())->after($this->mock($taggerEngine)->call('setSrcDirectory')->withArguments($pusher->getWorkingDirectory())->once())->after($this->mock($taggerEngine)->call('setVersion')->withArguments('$Rev:' . ' 0.0.1 $')->once())->once()->call('tagVersion')->before($this->mock($git)->call('addAllAndCommit')->withArguments('Set version to dev-master.')->once())->after($this->mock($taggerEngine)->call('setSrcDirectory')->withArguments($pusher->getWorkingDirectory())->once())->after($this->mock($taggerEngine)->call('setVersion')->withArguments('$Rev:' . ' dev-master $')->once())->once()->if($pusher->tagPatchVersion())->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '0.0.1')->twice()->if($pusher->tagMinorVersion())->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '0.1.0')->once()->if($pusher->tagMajorVersion())->then->object($pusher->run())->isIdenticalTo($pusher)->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '1.0.0')->once()->assert('Pusher should write error if pushing tag failed and should try to reset repository')->if($pusher->tagPatchVersion(), $this->calling($git)->pushTag->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~2')->once()->call('deleteLocalTag')->withArguments('0.0.1')->once()->assert('Pusher should write error if pushing commit failed and should try to reset repository')->if($this->calling($git)->push->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~2')->once()->call('deleteLocalTag')->withArguments('0.0.1')->once()->assert('Pusher should write error if pushing commit for DEVELOPMENT version failed and should try to reset repository')->if($this->calling($git)->push = $git, $this->calling($git)->addAllAndCommit[2]->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~1')->once()->assert('Pusher should write error if pushing commit for DEVELOPMENT version failed and should try to reset repository')->if($this->calling($git)->createTag->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->once()->mock($git)->call('resetHardTo')->withArguments('HEAD~1')->once()->assert('Pusher should write error if commit failed for STABLE version and should try to reset repository')->if($this->calling($git)->createTag = $git, $this->calling($git)->addAllAndCommit[1]->throw = $exception = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($exception->getMessage())->after($this->mock($git)->call('addAllAndCommit'))->once()->mock($git)->call('checkoutAllFiles')->after($this->mock($git)->call('addAllAndCommit'))->once()->assert('Pusher should write error if reset failed')->if($this->calling($git)->checkoutAllFiles->throw = $checkoutAllFilesException = new \exception(uniqid()))->then->object($pusher->run())->isIdenticalTo($pusher)->mock($errorWriter)->call('write')->withArguments($checkoutAllFilesException->getMessage())->once();
}
示例11: get_exception_info
/**
* Returns detailed information about specified exception.
* @param exception $ex
* @return object
*/
function get_exception_info($ex)
{
global $CFG, $DB, $SESSION;
if ($ex instanceof moodle_exception) {
$errorcode = $ex->errorcode;
$module = $ex->module;
$a = $ex->a;
$link = $ex->link;
$debuginfo = $ex->debuginfo;
} else {
$errorcode = 'generalexceptionmessage';
$module = 'error';
$a = $ex->getMessage();
$link = '';
$debuginfo = '';
}
// Append the error code to the debug info to make grepping and googling easier
$debuginfo .= PHP_EOL . "Error code: {$errorcode}";
$backtrace = $ex->getTrace();
$place = array('file' => $ex->getFile(), 'line' => $ex->getLine(), 'exception' => get_class($ex));
array_unshift($backtrace, $place);
// Be careful, no guarantee moodlelib.php is loaded.
if (empty($module) || $module == 'moodle' || $module == 'core') {
$module = 'error';
}
// Search for the $errorcode's associated string
// If not found, append the contents of $a to $debuginfo so helpful information isn't lost
if (function_exists('get_string_manager')) {
if (get_string_manager()->string_exists($errorcode, $module)) {
$message = get_string($errorcode, $module, $a);
} elseif ($module == 'error' && get_string_manager()->string_exists($errorcode, 'moodle')) {
// Search in moodle file if error specified - needed for backwards compatibility
$message = get_string($errorcode, 'moodle', $a);
} else {
$message = $module . '/' . $errorcode;
$debuginfo .= PHP_EOL . '$a contents: ' . print_r($a, true);
}
} else {
$message = $module . '/' . $errorcode;
$debuginfo .= PHP_EOL . '$a contents: ' . print_r($a, true);
}
// Remove some absolute paths from message and debugging info.
$searches = array();
$replaces = array();
$cfgnames = array('tempdir', 'cachedir', 'localcachedir', 'themedir', 'dataroot', 'dirroot');
foreach ($cfgnames as $cfgname) {
if (property_exists($CFG, $cfgname)) {
$searches[] = $CFG->{$cfgname};
$replaces[] = "[{$cfgname}]";
}
}
if (!empty($searches)) {
$message = str_replace($searches, $replaces, $message);
$debuginfo = str_replace($searches, $replaces, $debuginfo);
}
// Be careful, no guarantee weblib.php is loaded.
if (function_exists('clean_text')) {
$message = clean_text($message);
} else {
$message = htmlspecialchars($message);
}
if (!empty($CFG->errordocroot)) {
$errordoclink = $CFG->errordocroot . '/en/';
} else {
$errordoclink = get_docs_url();
}
if ($module === 'error') {
$modulelink = 'moodle';
} else {
$modulelink = $module;
}
$moreinfourl = $errordoclink . 'error/' . $modulelink . '/' . $errorcode;
if (empty($link)) {
if (!empty($SESSION->fromurl)) {
$link = $SESSION->fromurl;
unset($SESSION->fromurl);
} else {
$link = $CFG->wwwroot . '/';
}
}
// When printing an error the continue button should never link offsite.
// We cannot use clean_param() here as it is not guaranteed that it has been loaded yet.
$httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
if (stripos($link, $CFG->wwwroot) === 0) {
// Internal HTTP, all good.
} else {
if (!empty($CFG->loginhttps) && stripos($link, $httpswwwroot) === 0) {
// Internal HTTPS, all good.
} else {
// External link spotted!
$link = $CFG->wwwroot . '/';
}
}
$info = new stdClass();
$info->message = $message;
//.........这里部分代码省略.........
示例12: log
/**
* Virhelogi
*
* @param string $message Virheviesti
* @param exception|string $exception $exception Exception
*/
private function log($message, $exception = '')
{
if (self::LOGGING == true) {
$timestamp = date('d.m.y H:i:s');
$message = utf8_encode($message);
if ($exception != '') {
$message .= " (" . $exception->getMessage() . ") faultcode: " . $exception->faultcode;
}
$message .= "\n";
error_log("{$timestamp}: {$message}", 3, '/tmp/lumo_log.txt');
}
}
示例13: text
/**
* Get a single line of text representing the exception:
*
* Error [ Code ]: Message ~ File [ Line ]
*
* @param object Exception
* @return string
*/
public static function text(exception $e)
{
return sprintf('Message: %s ERROR: %s Code:[ %s ] Fiel: %s ~ Line [ %d ]', strip_tags($e->getMessage()), get_class($e), $e->getCode(), $e->getFile(), $e->getLine());
}
示例14: handle_exceptions
/**
* Function handle_exceptions
*
* * @param exception $e
* @return void
*/
function handle_exceptions(exception $e)
{
global $msg;
$trace = $e->getTrace();
file_put_contents(_LOG_PATH_ . 'admin.exception.log', print_r($trace, true), FILE_APPEND);
$msg .= $e->getMessage();
return 'logout';
}
示例15: send_error
/**
* Send the error information to the WS client
* formatted as XML document.
* @param exception $ex
* @return void
*/
protected function send_error($ex = null)
{
// Zend Soap server fault handling is incomplete compared to XML-RPC :-(
// we can not use: echo $this->zend_server->fault($ex);
//TODO: send some better response in XML
if ($ex) {
$info = $ex->getMessage();
if (debugging() and isset($ex->debuginfo)) {
$info .= ' - ' . $ex->debuginfo;
}
} else {
$info = 'Unknown error';
}
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><SOAP-ENV:Fault>
<faultcode>MOODLE:error</faultcode>
<faultstring>' . $info . '</faultstring>
</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>';
$this->send_headers();
header('Content-Type: application/xml; charset=utf-8');
header('Content-Disposition: inline; filename="response.xml"');
echo $xml;
}