Skip to content

Commit

Permalink
Implement SessionVariableNotFound exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Dec 18, 2011
1 parent 7caa8a3 commit d0cfb45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions application/MantisBT/Exception/Session/SessionVariableNotFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Session;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class SessionVariableNotFound extends ExceptionAbstract {
public function __construct($variableName) {
$errorMessage = lang_get(ERROR_SESSION_VAR_NOT_FOUND, null, false);
$errorMessage = sprintf($errorMessage, $variableName);
parent::__construct(ERROR_SESSION_VAR_NOT_FOUND, $errorMessage, null);
$this->responseCode = 500;
}
}
5 changes: 3 additions & 2 deletions application/core/session_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* @uses php_api.php
*/

use MantisBT\Exception\Session\SessionVariableNotFound;

require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'error_api.php' );
Expand Down Expand Up @@ -148,8 +150,7 @@ function get( $p_name, $p_default=null ) {
return $p_default;
}

error_parameters( $p_name );
trigger_error( ERROR_SESSION_VAR_NOT_FOUND, ERROR );
throw new SessionVariableNotFound( $p_name );
}

/**
Expand Down

0 comments on commit d0cfb45

Please sign in to comment.