* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3 * @package SWDB */ require_once(PATH::PAGE . "Page.php"); /** * Error page model. * * @category Page */ class Error_Page extends Page{ /** * @var int Error code. */ private $code = 500; /** * @var string Error description. */ private $message = ""; /** * Constructor. * * Retrieves the data and initializes the variables. * * @param int $code HTTP Error code. Optional, default 500. */ public function __construct($code = null){ $this->view = PATH::VIEW . "error.php"; $this->title = "Error - SWDB"; if (null == $code || intval($code) < 200 || intval($code) > 599){ $code = 500; } switch(intval($code)){ case 400: $this->message = "Invalid request"; break; case 404: $this->message = "Not found"; break; case 500: $this->message = "Server error"; break; default: $this->message = "Unknown error"; } $this->code = intval($code); } /** * Retrieves the error code. * * @return int HTTP error code */ public function get_code(){ return $this->code; } /** * Retrieves the error description. * * @return int HTTP error description. */ public function get_message(){ return $this->message; } }