Advertisement
carefulnow

PHPForum Error Handler Message

Jun 1st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. The following line is really awful, but needs to be one big line so the textarea formatting looks right.
  2.  
  3. <textarea style='resize: none; width: 80%; height: 6em; background-color: #888;' readonly>" . $_SERVER["REQUEST_URI"] . " via " . $_SERVER["REQUEST_METHOD"] . " @ " . time() . " -- " . get_class($e) . ": " . (($e->getMessage() === "") ? "No message provided" : $e->getMessage()) . "\n\nSQLSTATE: " . ((isset($errInf[0])) ? $errInf[0] : "Not provided") . "\nDriver Error Code: " . ((isset($errInf[1])) ? $errInf[1] : "Not provided") . "\nDriver Error Message: " . ((isset($errInf[2])) ? $errInf[2] : "Not provided") . "</textarea>";
  4.  
  5. An example output would be:
  6.  
  7. /login.php?login via POST @ 1496336860 -- PDOException: Inco
  8.  
  9. SQLSTATE: 00000
  10. Driver Error Code: Not provided
  11. Driver Error Message: Not provided
  12.  
  13. It consists of the page ($_SERVER["REQUEST_URI"]) and the method (normally GET or POST, $_SERVER["REQUEST_METHOD"]). It then provides the time, in the form of a Unix timestamp (time()), and then the type of exception thrown, got by get_class($exception), and then the message that the exception contains ($exception->getMessage()).
  14.  
  15. Then, if get_class($exception) returned "PDOException", something went wrong with the database. Therefore, it shows some database error information obtained using the errorInfo() method on the static PDO $db object. More info on what errorInfo() returns can be found on the official PHP documentation: http://php.net/manual/en/pdo.errorinfo.php.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement