本文整理汇总了PHP中get_exception_info函数的典型用法代码示例。如果您正苦于以下问题:PHP get_exception_info函数的具体用法?PHP get_exception_info怎么用?PHP get_exception_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_exception_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: data_to_string
/**
* Convert data attribute to a string
*
* @param \core_renderer $output
* @return string
*/
protected function data_to_string(\core_renderer $output)
{
if ($this->data instanceof \Exception) {
$info = get_exception_info($this->data);
return $output->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
} else {
return json_encode($this->data);
}
}
示例2: get_exception_handler
/**
* Silent exception handler.
*
* @return callable exception handler
*/
public static function get_exception_handler()
{
return function ($ex) {
$info = get_exception_info($ex);
$logerrmsg = "enrol_paypal IPN exception handler: " . $info->message;
if (debugging('', DEBUG_NORMAL)) {
$logerrmsg .= ' Debug: ' . $info->debuginfo . "\n" . format_backtrace($info->backtrace, true);
}
error_log($logerrmsg);
exit(0);
};
}
示例3: upgrade_handle_exception
/**
* upgrade logging functions
*/
function upgrade_handle_exception($ex, $plugin = null) {
global $CFG;
// rollback everything, we need to log all upgrade problems
abort_all_db_transactions();
$info = get_exception_info($ex);
// First log upgrade error
upgrade_log(UPGRADE_LOG_ERROR, $plugin, 'Exception: ' . get_class($ex), $info->message, $info->backtrace);
// Always turn on debugging - admins need to know what is going on
set_debugging(DEBUG_DEVELOPER, true);
default_exception_handler($ex, true, $plugin);
}
示例4: judge_all_unjudged
function judge_all_unjudged()
{
while ($task = get_one_unjudged_task()) {
verbose(cli_heading('TASK: ' . $task->id, true));
verbose('Judging...');
try {
$task = onlinejudge_judge($task);
verbose("Successfully judged: {$task->status}");
} catch (Exception $e) {
$info = get_exception_info($e);
$errmsg = "Judged inner level exception handler: " . $info->message . ' Debug: ' . $info->debuginfo . "\n" . format_backtrace($info->backtrace, true);
cli_problem($errmsg);
// Continue to get next unjudged task
}
}
}
示例5: call_external_function
/**
* Call an external function validating all params/returns correctly.
*
* Note that an external function may modify the state of the current page, so this wrapper
* saves and restores tha PAGE and COURSE global variables before/after calling the external function.
*
* @param string $function A webservice function name.
* @param array $args Params array (named params)
* @param boolean $ajaxonly If true, an extra check will be peformed to see if ajax is required.
* @return array containing keys for error (bool), exception and data.
*/
public static function call_external_function($function, $args, $ajaxonly = false)
{
global $PAGE, $COURSE, $CFG, $SITE;
require_once $CFG->libdir . "/pagelib.php";
$externalfunctioninfo = self::external_function_info($function);
$currentpage = $PAGE;
$currentcourse = $COURSE;
$response = array();
try {
// Taken straight from from setup.php.
if (!empty($CFG->moodlepageclass)) {
if (!empty($CFG->moodlepageclassfile)) {
require_once $CFG->moodlepageclassfile;
}
$classname = $CFG->moodlepageclass;
} else {
$classname = 'moodle_page';
}
$PAGE = new $classname();
$COURSE = clone $SITE;
if ($ajaxonly && !$externalfunctioninfo->allowed_from_ajax) {
throw new moodle_exception('servicenotavailable', 'webservice');
}
// Do not allow access to write or delete webservices as a public user.
if ($externalfunctioninfo->loginrequired) {
if (defined('NO_MOODLE_COOKIES') && NO_MOODLE_COOKIES && !PHPUNIT_TEST) {
throw new moodle_exception('servicenotavailable', 'webservice');
}
if (!isloggedin()) {
throw new moodle_exception('servicenotavailable', 'webservice');
} else {
require_sesskey();
}
}
// Validate params, this also sorts the params properly, we need the correct order in the next part.
$callable = array($externalfunctioninfo->classname, 'validate_parameters');
$params = call_user_func($callable, $externalfunctioninfo->parameters_desc, $args);
// Execute - gulp!
$callable = array($externalfunctioninfo->classname, $externalfunctioninfo->methodname);
$result = call_user_func_array($callable, array_values($params));
// Validate the return parameters.
if ($externalfunctioninfo->returns_desc !== null) {
$callable = array($externalfunctioninfo->classname, 'clean_returnvalue');
$result = call_user_func($callable, $externalfunctioninfo->returns_desc, $result);
}
$response['error'] = false;
$response['data'] = $result;
} catch (Exception $e) {
$exception = get_exception_info($e);
unset($exception->a);
if (!debugging('', DEBUG_DEVELOPER)) {
unset($exception->debuginfo);
unset($exception->backtrace);
}
$response['error'] = true;
$response['exception'] = $exception;
// Do not process the remaining requests.
}
$PAGE = $currentpage;
$COURSE = $currentcourse;
return $response;
}
示例6: lti_extend_lti_services
/**
* Extend the LTI services through the ltisource plugins
*
* @param stdClass $data LTI request data
* @return bool
* @throws coding_exception
*/
function lti_extend_lti_services($data)
{
$plugins = get_plugin_list_with_function('ltisource', $data->messagetype);
if (!empty($plugins)) {
try {
// There can only be one
if (count($plugins) > 1) {
throw new coding_exception('More than one ltisource plugin handler found');
}
$callback = current($plugins);
call_user_func($callback, $data);
} catch (moodle_exception $e) {
$error = $e->getMessage();
if (debugging('', DEBUG_DEVELOPER)) {
$error .= ' ' . format_backtrace(get_exception_info($e)->backtrace);
}
$responsexml = lti_get_response_xml('failure', $error, $data->messageid, $data->messagetype);
header('HTTP/1.0 400 bad request');
echo $responsexml->asXML();
}
return true;
}
return false;
}
示例7: lti_log_response
/**
* Log an LTI response.
*
* @param string $responsexml The response XML
* @param Exception $e If there was an exception, pass that too
*/
function lti_log_response($responsexml, $e = null)
{
if ($tempdir = make_temp_directory('mod_lti', false)) {
if ($tempfile = tempnam($tempdir, 'mod_lti_response' . date('YmdHis'))) {
$content = '';
if ($e instanceof Exception) {
$info = get_exception_info($e);
$content .= "Exception:\n";
$content .= "Message: {$info->message}\n";
$content .= "Debug info: {$info->debuginfo}\n";
$content .= "Backtrace:\n";
$content .= format_backtrace($info->backtrace, true);
$content .= "\n";
}
$content .= "Response XML:\n";
$content .= $responsexml;
file_put_contents($tempfile, $content);
chmod($tempfile, 0644);
}
}
}
示例8: RWSEHdlr
function RWSEHdlr($r_ex)
{
abort_all_db_transactions();
$r_inf = get_exception_info($r_ex);
$r_msg = "\r\n-- Exception occurred --";
$r_msg .= "\r\nmessage: {$r_inf->message}";
$r_msg .= "\r\nerrorcode: {$r_inf->errorcode}";
$r_msg .= "\r\nfile: " . $r_ex->getFile();
$r_msg .= "\r\nline: " . $r_ex->getLine();
$r_msg .= "\r\nlink: {$r_inf->link}";
$r_msg .= "\r\nmoreinfourl: {$r_inf->moreinfourl}";
$r_msg .= "\r\na: {$r_inf->a}";
$r_msg .= "\r\ndebuginfo: {$r_inf->debuginfo}\r\n";
RWSELog($r_msg);
RWSELog("\r\nstacktrace: " . $r_ex->getTraceAsString());
RWSSErr("2112,{$r_inf->errorcode}");
}
示例9: handle
/**
* Echo an exception message encapsulated in XML.
*
* @param \Exception $exception The exception that was thrown
*/
public function handle(\Exception $exception)
{
$message = $exception->getMessage();
// Add the exception backtrace for developers.
if (debugging('', DEBUG_DEVELOPER)) {
$message .= "\n" . format_backtrace(get_exception_info($exception)->backtrace, true);
}
// Switch to response.
$type = str_replace('Request', 'Response', $this->type);
// Build the appropriate xml.
$response = lti_get_response_xml('failure', $message, $this->id, $type);
$xml = $response->asXML();
// Log the request if necessary.
if ($this->log) {
lti_log_response($xml, $exception);
}
echo $xml;
}
示例10: test_exception_info_removes_serverpaths
/**
* Test if get_exception_info() removes file system paths.
*/
public function test_exception_info_removes_serverpaths()
{
global $CFG;
// This doesn't test them all possible ones, but these are set for unit tests.
$cfgnames = array('dataroot', 'dirroot', 'tempdir', 'cachedir', 'localcachedir');
$fixture = '';
$expected = '';
foreach ($cfgnames as $cfgname) {
if (!empty($CFG->{$cfgname})) {
$fixture .= $CFG->{$cfgname} . ' ';
$expected .= "[{$cfgname}] ";
}
}
$exception = new moodle_exception('generalexceptionmessage', 'error', '', $fixture, $fixture);
$exceptioninfo = get_exception_info($exception);
$this->assertContains($expected, $exceptioninfo->message, 'Exception message does not contain system paths');
$this->assertContains($expected, $exceptioninfo->debuginfo, 'Exception debug info does not contain system paths');
}
示例11: error_log
// Do not allow access to write or delete webservices as a public user.
if ($externalfunctioninfo->loginrequired) {
if (!isloggedin()) {
error_log('This external function is not available to public users. Failed to call "' . $methodname . '"');
throw new moodle_exception('servicenotavailable', 'webservice');
}
}
// Validate params, this also sorts the params properly, we need the correct order in the next part.
$callable = array($externalfunctioninfo->classname, 'validate_parameters');
$params = call_user_func($callable, $externalfunctioninfo->parameters_desc, $args);
// Execute - gulp!
$callable = array($externalfunctioninfo->classname, $externalfunctioninfo->methodname);
$result = call_user_func_array($callable, array_values($params));
$response['error'] = false;
$response['data'] = $result;
$responses[$index] = $response;
} catch (Exception $e) {
$jsonexception = get_exception_info($e);
unset($jsonexception->a);
if (!debugging('', DEBUG_DEVELOPER)) {
unset($jsonexception->debuginfo);
unset($jsonexception->backtrace);
}
$response['error'] = true;
$response['exception'] = $jsonexception;
$responses[$index] = $response;
// Do not process the remaining requests.
break;
}
}
echo json_encode($responses);
示例12: mod_paypal_ipn_exception_handler
/**
* Silent exception handler.
*
* @param Exception $ex
* @return void - does not return. Terminates execution!
*/
function mod_paypal_ipn_exception_handler($ex)
{
$info = get_exception_info($ex);
$logerrmsg = "mod_paypal IPN exception handler: " . $info->message;
if (debugging('', DEBUG_NORMAL)) {
$logerrmsg .= ' Debug: ' . $info->debuginfo . "\n" . format_backtrace($info->backtrace, true);
}
error_log($logerrmsg);
exit(0);
}
示例13: lockdownbrowser_MonitorExceptionHandler
function lockdownbrowser_MonitorExceptionHandler($ex)
{
abort_all_db_transactions();
$info = get_exception_info($ex);
$msg = "\r\n-- Exception occurred --" . "\r\nmessage: {$info->message}" . "\r\nerrorcode: {$info->errorcode}" . "\r\nbacktrace: {$info->backtrace}" . "\r\nlink: {$info->link}" . "\r\nmoreinfourl: {$info->moreinfourl}" . "\r\na: {$info->a}" . "\r\ndebuginfo: {$info->debuginfo}\r\n";
lockdownbrowser_MonitorLog($msg);
lockdownbrowser_MonitorLog("\r\nstacktrace: " . $ex->getTraceAsString());
lockdownbrowser_MonitorServiceError(2003, "A Moodle or PHP server exception occurred: {$info->errorcode}");
}
示例14: get_exception_info
/**
* Wrapper to call {@link get_exception_info()}.
*
* @param Exception $ex An exception.
* @return stdClass of information.
*/
public function get_exception_info($ex)
{
try {
throw $ex;
} catch (moodle_exception $e) {
return get_exception_info($e);
}
}
示例15: deploy_ingredients
/**
* Adds and upgrades the selected plugins
*
* @param array $ingredients
* @param string $path Path to the ingredient type file system
* @param SimpleXMLElement $xml
* @return array Problems during the ingredients deployment
*/
public function deploy_ingredients($ingredients, $path, SimpleXMLElement $xml)
{
// Using the $ingredients array keys to maintain coherence with the main deployment method
$problems = array();
$pluginman = plugin_manager::instance();
$plugintypespaths = get_plugin_types();
$this->get_flavour_info($xml);
foreach ($ingredients as $selection) {
// [0] => ingredienttype, [1] => ingredientname
$ingredientdata = explode('/', $selection);
$type = $ingredientdata[0];
$ingredient = $ingredientdata[1];
if (empty($this->branches[$type]->branches[$ingredient])) {
$problems[$selection]['pluginnotfound'] = $selection;
continue;
}
$ingredientdata = $this->branches[$type]->branches[$ingredient];
// Adapter to the restrictions array
if (!empty($ingredientdata->restrictions)) {
$problems[$selection] = $ingredientdata->restrictions;
continue;
}
if (empty($xml->{$type}) || empty($xml->{$type}->{$ingredient})) {
$problems[$selection]['pluginnotfound'] = $selection;
continue;
}
// Deploy then
$ingredientpath = $plugintypespaths[$type] . '/' . $ingredient;
// Remove old dir if present
if (file_exists($ingredientpath)) {
// Report if the old plugin directory can't be removed
if (!$this->unlink($ingredientpath)) {
$problems[$selection]['plugincantremove'] = $selection;
continue;
}
}
// Copy the new contents where the flavour says
$tmppath = $path . '/' . $xml->{$type}->{$ingredient}->path;
if (!$this->copy($tmppath, $ingredientpath)) {
debugging('From : ' . $tmppath . ' To: ' . $ingredientpath);
$problems[$selection]['plugincopyerror'] = $selection;
}
}
// Execute the moodle upgrade process
try {
foreach ($plugintypespaths as $type => $location) {
upgrade_plugins($type, 'flavours_print_upgrade_void', 'flavours_print_upgrade_void', false);
}
} catch (Exception $ex) {
abort_all_db_transactions();
$info = get_exception_info($ex);
upgrade_log(UPGRADE_LOG_ERROR, $ex->module, 'Exception: ' . get_class($ex), $info->message, $info->backtrace);
}
return $problems;
}