diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php index 796681c423fb7a502a0b617de376251a92f69221..af86ae4c07b02b69928cb10e8f5314e7cc19b3e5 100644 --- a/lib/SimpleSAML/Error/Error.php +++ b/lib/SimpleSAML/Error/Error.php @@ -18,6 +18,30 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception { private $errorCode; + /** + * The error title tag in dictionary. + * + * @var string + */ + private $dictTitle; + + + /** + * The error description tag in dictionary. + * + * @var string + */ + private $dictDescr; + + + /** + * The name of module which throw error. + * + * @var string|NULL + */ + private $module = NULL; + + /** * The parameters for the error. * @@ -48,6 +72,16 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception { $this->errorCode = $errorCode; } + $moduleCode = explode(':', $this->errorCode, 2); + if (count($moduleCode) === 2) { + $this->module = $moduleCode[0]; + $this->dictTitle = '{' . $this->module . ':errors:title_' . $moduleCode[1] . '}'; + $this->dictDescr = '{' . $this->module . ':errors:descr_' . $moduleCode[1] . '}'; + } else { + $this->dictTitle = '{errors:title_' . $this->errorCode . '}'; + $this->dictDescr = '{errors:descr_' . $this->errorCode . '}'; + } + if (!empty($this->parameters)) { $msg = $this->errorCode . '('; foreach ($this->parameters as $k => $v) { @@ -75,6 +109,36 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception { } + /** + * Retrieve the error parameters given when throwing this error. + * + * @return array The parameters. + */ + public function getParameters() { + return $this->parameters; + } + + + /** + * Retrieve the error title tag in dictionary. + * + * @return string The error title tag. + */ + public function getDictTitle() { + return $this->dictTitle; + } + + + /** + * Retrieve the error description tag in dictionary. + * + * @return string The error description tag. + */ + public function getDictDescr() { + return $this->dictDescr; + } + + /** * Set the HTTP return code for this error. * @@ -150,6 +214,9 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception { $data['error'] = $errorData; $data['errorCode'] = $this->errorCode; $data['parameters'] = $this->parameters; + $data['module'] = $this->module; + $data['dictTitle'] = $this->dictTitle; + $data['dictDescr'] = $this->dictDescr; /* Check if there is a valid technical contact email address. */ if($config->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') { diff --git a/templates/error.php b/templates/error.php index c40fa079044767d977a2102ee55bd845986b63f9..b9603a4351d91b6e455e17107ef5b9c014725f06 100644 --- a/templates/error.php +++ b/templates/error.php @@ -9,10 +9,10 @@ ?> - <h2><?php echo $this->t('title_' . $this->data['errorCode']); ?></h2> + <h2><?php echo $this->t($this->data['dictTitle']); ?></h2> <?php -echo htmlspecialchars($this->t('descr_' . $this->data['errorCode'], $this->data['parameters'])); +echo htmlspecialchars($this->t($this->data['dictDescr'], $this->data['parameters'])); ?> <div class="trackidtext">