error.php
Error handler
Zed. The immensity of stars. The HyperShip. The people.
(c) 2010, Dereckson, some rights reserved. Released under BSD license.
This error handler uses the same idea and message_die method signature of the phpBB 2 one.
Tags
Table of Contents
Constants
- GENERAL_ERROR = 117
- GENERAL_ERROR is the constant meaning the error is general, ie not covered by another more specific error constant.
- HACK_ERROR = 99
- HACK_ERROR is the constant meaning access is non authorized to the resource.
- SQL_ERROR = 65
- SQL_ERROR is the constant meaning the error is a SQL error.
Functions
- dieprint_r() : never
- Output a general error, with human-readable information about the specified expression as error message ; terminates the current script.
- message_die() : never
- Outputs an error message and terminates the current script.
- old_message_die() : never
- Outputs an error message and terminates the current script.
Constants
GENERAL_ERROR
GENERAL_ERROR is the constant meaning the error is general, ie not covered by another more specific error constant.
public
mixed
GENERAL_ERROR
= 117
HACK_ERROR
HACK_ERROR is the constant meaning access is non authorized to the resource.
public
mixed
HACK_ERROR
= 99
It encompasses two problematics: the URL points to a resource belonging to another user or for the current user have no access right (for malformed URL, pick instead GENERAL_ERROR) ; the user is anonymous, instead to be logged in.
A suggested way to handle the second problematic is to store in hidden input fields or better in the session the previous form data, and to print a login form.
If you implement this, you don't even need to distinguish between the two cases, as once logged in, the regular HACK_ERROR could also be printed.
SQL_ERROR
SQL_ERROR is the constant meaning the error is a SQL error.
public
mixed
SQL_ERROR
= 65
As a message_die function parameter, it allows to add SQL specific debug information.
Functions
dieprint_r()
Output a general error, with human-readable information about the specified expression as error message ; terminates the current script.
dieprint_r(mixed $expression[, string $title = '' ]) : never
Parameters
- $expression : mixed
-
the expression to be printed
- $title : string = ''
-
the message title (optional, default will be 'Debug')
Tags
Return values
nevermessage_die()
Outputs an error message and terminates the current script.
message_die(int $msg_code[, string $msg_text = '' ][, string $msg_title = '' ][, string $err_line = '' ][, mixed $err_file = '' ][, string $sql = '' ]) : never
Error will be output through Smarty one of the following templates : error_block.tpl if the header have already been printed ; error.tpl if the error occurred before the header were called and printed.
If smarty couldn't be loaded, old_message_die method will be called, which produces a table output.
Parameters
- $msg_code : int
-
an integer constant identifying the error (HACK_ERROR, SQL_ERROR, GENERAL_ERROR)
- $msg_text : string = ''
-
the error message text (optional, but recommended)
- $msg_title : string = ''
-
the error message title (optional)
- $err_line : string = ''
-
the path of file where the error occurred (optional, suggested value is FILE)
- $err_file : mixed = ''
- $sql : string = ''
-
the SQL query (optional, used only if msg_code is SQL_ERROR)
Return values
neverold_message_die()
Outputs an error message and terminates the current script.
old_message_die(int $msg_code[, string $msg_text = '' ][, string $msg_title = '' ][, string $err_line = '' ][, mixed $err_file = '' ][, string $sql = '' ]) : never
This is the message_die method from Espace Win, used on Zed as fallback if Smarty isn't initialized yet. Former "german style" error HTML markups have been removed.
Parameters
- $msg_code : int
-
an integer constant identifying the error (HACK_ERROR, SQL_ERROR, GENERAL_ERROR)
- $msg_text : string = ''
-
the error message text (optional, but recommended)
- $msg_title : string = ''
-
the error message title (optional)
- $err_line : string = ''
-
the path of file where the error occurred (optional, suggested value is FILE)
- $err_file : mixed = ''
- $sql : string = ''
-
the SQL query (optional, used only if msg_code is SQL_ERROR)