ctools_shutdown_handler

  1. drupal
    1. 6 ctools.module function
    2. 7 ctools.module function
Drupal 7 ctools_shutdown_handler()

Shutdown handler used during ajax operations to help catch fatal errors.

1 string reference to 'ctools_shutdown_handler'

File

sites/all/modules/ctools/ctools.module, line 393
CTools primary module file.

Code

function ctools_shutdown_handler() {
  if (function_exists('error_get_last') AND ($error = error_get_last())) {
    switch ($error['type']) {
      case E_ERROR:
      case E_CORE_ERROR:
      case E_COMPILE_ERROR:
      case E_USER_ERROR:
        // Do this manually because including files here is dangerous.
        $commands = array(
          array(
            'command' => 'alert', 
            'title' => t('Error'), 
            'text' => t('Unable to complete operation. Fatal error in @file on line @line: @message', array(
              '@file' => $error['file'], 
              '@line' => $error['line'], 
              '@message' => $error['message'],
            )),
          ),
        );

        // Change the status code so that the client will read the AJAX returned.
        header('HTTP/1.1 200 OK');
        drupal_json($commands);
    }
  }
}