Author: ralfbecker
New Revision: 28969
URL: http://www.egroupware.org/viewvc/egroupware?rev=28969&view=rev
Log:
refractored our exception handler a bit, to allow using part of it from ajax too. Ajax logs now the exception to the error_log and only shows a trace to the user if enabled in the config, like the rest of EGroupware
Modified:
trunk/egroupware/xajax.php
trunk/phpgwapi/inc/common_functions.inc.php
Modified: trunk/egroupware/xajax.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/egroupware/xajax.php?rev=28969&r1=28968&r2=28969&view=diff
— trunk/egroupware/xajax.php (original)
+++ trunk/egroupware/xajax.php Fri Jan 15 00:50:06 2010
@@ -33,7 +33,7 @@
}
/**
-
- Exception handler for xajax, return the message (and trace) as alert() to the user
-
- Exception handler for xajax, return the message (and trace, if enabled) as alert() to the user
- Does NOT return!
@@ -41,8 +41,20 @@
*/
function ajax_exception_handler(Exception $e)
{
- // logging all exceptions to the error_log
- if (function_exists(’_egw_log_exception’))
- {
-
_egw_log_exception($e,$message); - }
$response = new xajaxResponse();
- $response->addAlert($e->getMessage()."\n\n".$e->getTraceAsString());
-
$message .= ($message ? “\n\n” : ‘’).$e->getMessage();
-
// only show trace (incl. function arguments) if explicitly enabled, eg. on a development system
-
if ($GLOBALS[‘egw_info’][‘server’][‘exception_show_trace’])
-
{
-
$message .= "\n\n".$e->getTraceAsString(); -
}
-
$response->addAlert($message);
$response->printOutput();if (is_object($GLOBALS[‘egw’]))
Modified: trunk/phpgwapi/inc/common_functions.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/phpgwapi/inc/common_functions.inc.php?rev=28969&r1=28968&r2=28969&view=diff
— trunk/phpgwapi/inc/common_functions.inc.php (original)
+++ trunk/phpgwapi/inc/common_functions.inc.php Fri Jan 15 00:50:06 2010
@@ -1422,6 +1422,41 @@
}
/**
-
- Clasify exception for a headline and log it to error_log, if not running as cli
-
-
- @param Exception $e
-
- @param string &$headline
- */
+function _egw_log_exception(Exception $e,&$headline=null)
+{ - if ($e instanceof egw_exception_no_permission)
- {
-
$headline = try_lang('Permission denied!'); - }
- elseif ($e instanceof egw_exception_db)
- {
-
$headline = try_lang('Database error'); - }
- elseif ($e instanceof egw_exception_wrong_userinput)
- {
-
$headline = ''; // message contains the whole message, it's usually no real error but some input validation - }
- else
- {
-
$headline = try_lang('An error happened'); - }
- // log exception to error log, if not running as cli,
- // which outputs the error_log to stderr and therefore output it twice to the user
- if(!isset($_SERVER[‘HTTP_HOST’]) || $GLOBALS[‘egw_info’][‘flags’][‘no_exception_handler’] == ‘cli’)
- {
-
error_log($headline.': '.$e->getMessage()); -
foreach(explode("\n",$e->getTraceAsString()) as $line) error_log($line); -
error_log('# Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid'].', URL='. -
($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); - }
+}
+/**
- Fail a little bit more gracefully then an uncought exception
- Does NOT return
@@ -1430,22 +1465,9 @@
*/
function egw_exception_handler(Exception $e)
{
- if ($e instanceof egw_exception_no_permission)
- {
-
$headline = try_lang('Permission denied!'); - }
- elseif ($e instanceof egw_exception_db)
- {
-
$headline = try_lang('Database error'); - }
- elseif ($e instanceof egw_exception_wrong_userinput)
- {
-
$headline = ''; // message contains the whole message, it's usually no real error but some input validation - }
- else
- {
-
$headline = try_lang('An error happened'); - }
- // logging all exceptions to the error_log (if not cli) and get headline
- _egw_log_exception($e,$headline);
- // exception handler for cli (command line interface) clients, no html, no logging
if(!isset($_SERVER[‘HTTP_HOST’]) || $GLOBALS[‘egw_info’][‘flags’][‘no_exception_handler’] == ‘cli’)
{
@@ -1456,12 +1478,6 @@
}
exit($e->getCode() ? $e->getCode() : 9999); // allways give a non-zero exit code
}
- // logging all exceptions to the error_log
- error_log($headline.’: '.$e->getMessage());
- foreach(explode("\n",$e->getTraceAsString()) as $line) error_log($line);
- error_log(’# Instance=’.$GLOBALS[‘egw_info’][‘user’][‘domain’].’, User=’.$GLOBALS[‘egw_info’][‘user’][‘account_lid’].’, URL=’.
-
($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); - // regular GUI exception
if (!isset($GLOBALS[‘egw_info’][‘flags’][‘no_exception_handler’]))
{
@@ -1494,9 +1510,9 @@
header(‘HTTP/1.1 401 Unauthorized’);
header(‘X-WebDAV-Status: 401 Unauthorized’, true);
} - if (is_object($GLOBALS[‘egw’]) && isset($GLOBALS[‘egw’]->common))
- {
-
$GLOBALS['egw']->common->egw_exit();
- if (is_object($GLOBALS[‘egw’]))
- {
-
}common::egw_exit();
exit;
}
Throughout its 18-year history, RSA Conference consistently attracts the
world’s best and brightest in the field, creating opportunities for Conference
attendees to learn about information security’s most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs