Commit 0690ffa951d0a4f2eb8428ee504dfcf5f5bb539c
1 parent
c1057af2
Cater for error viewers and default messages - default messages will
only be used if another message isn't forthcoming - from a PEAR Error instance, for example. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4122 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
17 additions
and
4 deletions
lib/validation/dispatchervalidation.inc.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +require_once(KT_LIB_DIR . '/validation/errorviewer.inc.php'); | |
| 4 | + | |
| 3 | 5 | class KTDispatcherValidation { |
| 4 | 6 | function KTDispatcherValidation(&$oDispatcher) { |
| 5 | 7 | $this->oDispatcher =& $oDispatcher; |
| ... | ... | @@ -76,18 +78,29 @@ class KTDispatcherValidation { |
| 76 | 78 | $aRedirectTo = KTUtil::arrayGet($aOptions, 'redirect_to'); |
| 77 | 79 | $oException = KTUtil::arrayGet($aOptions, 'exception'); |
| 78 | 80 | $sMessage = KTUtil::arrayGet($aOptions, 'message'); |
| 79 | - if (is_null($sMessage)) { | |
| 81 | + $sDefaultMessage = KTUtil::arrayGet($aOptions, 'defaultmessage'); | |
| 82 | + if (empty($sMessage)) { | |
| 80 | 83 | if ($oException) { |
| 81 | - $sMessage = $oException->toString(); | |
| 84 | + $oEVRegistry = KTErrorViewerRegistry::getSingleton(); | |
| 85 | + $oViewer = $oEVRegistry->getViewer($oException); | |
| 86 | + $sMessage = $oViewer->view(); | |
| 87 | + } elseif ($sDefaultMessage) { | |
| 88 | + $sMessage = $sDefaultMessage; | |
| 82 | 89 | } else { |
| 83 | 90 | $sMessage = "An error occurred, and no error message was given"; |
| 84 | 91 | } |
| 92 | + } else { | |
| 93 | + if ($oException) { | |
| 94 | + $sMessage .= ': ' . $oException->getMessage(); | |
| 95 | + } | |
| 85 | 96 | } |
| 86 | 97 | if ($aRedirectTo) { |
| 87 | - $aRealRedirectTo = array($aRedirectTo[0], $sMessage, KTUtil::arrayGet($aRedirectTo, 1)); | |
| 98 | + $aRedirectParams = KTUtil::arrayGet($aRedirectTo, 1); | |
| 99 | + $aRealRedirectTo = array($aRedirectTo[0], $sMessage, $aRedirectParams); | |
| 100 | + $aRealRedirectTo[] = $oException; | |
| 88 | 101 | call_user_func_array(array($this->oDispatcher, 'errorRedirectTo'), $aRealRedirectTo); |
| 89 | 102 | } |
| 90 | - $this->oDispatcher->errorPage($sMessage); | |
| 103 | + $this->oDispatcher->errorPage($sMessage, $oException); | |
| 91 | 104 | } |
| 92 | 105 | |
| 93 | 106 | function &validateTemplate($sTemplateName, $aOptions = null) { | ... | ... |