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


PHP get_exception_info函数代码示例

本文整理汇总了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);
     }
 }
开发者ID:cdsmith-umn,项目名称:moodle-mod_hsuforum,代码行数:15,代码来源:json_response.php

示例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);
     };
 }
开发者ID:janeklb,项目名称:moodle,代码行数:17,代码来源:util.php

示例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);
}
开发者ID:jtibbetts,项目名称:moodle,代码行数:19,代码来源:upgradelib.php

示例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
        }
    }
}
开发者ID:boychunli,项目名称:moodle-local_onlinejudge,代码行数:16,代码来源:judged.php

示例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;
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:73,代码来源:externallib.php

示例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;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:servicelib.php

示例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);
        }
    }
}
开发者ID:reconnectmedia,项目名称:moodle,代码行数:27,代码来源:locallib.php

示例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}");
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:17,代码来源:servicelib.php

示例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;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:23,代码来源:service_exception_handler.php

示例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');
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:21,代码来源:setuplib_test.php

示例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);
开发者ID:educakanchay,项目名称:campus,代码行数:31,代码来源:service.php

示例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);
}
开发者ID:danielneis,项目名称:moodle-mod_paypal,代码行数:16,代码来源:ipn.php

示例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}");
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:9,代码来源:monitor.php

示例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);
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:14,代码来源:setuplib_test.php

示例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;
 }
开发者ID:uofr,项目名称:moodle-local_flavours,代码行数:63,代码来源:flavours_ingredient_plugin.class.php


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