PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/error.php

https://github.com/t-hebert73/Personal-Website
PHP | 63 lines | 27 code | 8 blank | 28 comment | 1 complexity | bd98550c7bb9e0fcfeab9f33034f7cd7 MD5 | raw file
  1. <?php
  2. /**
  3. * File : Error.php
  4. * Last Motified : Feb 20, 2012
  5. * Description : Error class definition, used for error checking.
  6. * Requires sessions to work
  7. */
  8. class Error
  9. {
  10. // Member variables
  11. private $error;
  12. //private $param;
  13. // Constructor
  14. // Initializes an error
  15. // e - A string representing the error
  16. public function __construct($e)
  17. {
  18. // Set the error
  19. $this->error = $e;
  20. }
  21. // Returns the error code
  22. public function getError()
  23. {
  24. // Return the error
  25. return $this->error;
  26. }
  27. // Returns the paremeter
  28. // TODO
  29. // public function getParam();
  30. // Throws an error
  31. // This function sets an error for the next page to catch
  32. // Note : The errors will remain in the sessions until catched.
  33. public function _throw()
  34. {
  35. // Set the session for the error
  36. $_SESSION['error'] = serialize($this);
  37. }
  38. // Static catch function
  39. // Retrieves any errors from the sessions
  40. public static function _catch()
  41. {
  42. // Check to see if there are any errors
  43. if( isset($_SESSION['error']) )
  44. {
  45. // Get the error
  46. $e = unserialize($_SESSION['error']);
  47. // Delete the session
  48. unset($_SESSION['error']);
  49. // Return the error
  50. return $e;
  51. }
  52. // No errors found
  53. return null;
  54. }
  55. }