function ctools_shutdown_handler

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

1 string reference to 'ctools_shutdown_handler'
ctools_init in ./ctools.module
Implement hook_init to keep our global CSS at the ready.

File

./ctools.module, line 620

Code

function ctools_shutdown_handler() {
    if (function_exists('error_get_last') && ($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);
        }
    }
}