Error
Error
Basic controller class
This controller does basic stuff
Properties
type
protected int $type
errno
public string $errno
errstr
protected string $errstr
errfile
protected string $errfile
errline
protected int $errline
errtype
protected string $errtype
errclass
protected string $errclass
callstack
protected array $callstack
shortMessage
protected string $shortMessage
code
The HTTP error code to throw. By default it is 500 Internal Server Error.
protected int $code
status
protected string $status
responseType
protected string $responseType
status_codes
public array $status_codes
Methods
__construct
public __construct({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$name | string |
getStatusMessage
Retrieves the status message corresponding to a given status code.
public getStatusMessage({Array})
If no status code is provided, it uses the instance's current status code.
Parameters
Parameter | Type | Description |
---|---|---|
$code | int | The status code to get the message for. If null, the instance's current status code is used. |
setError
Sets the error details based on the provided arguments.
public setError({Array})
This method can handle different types of errors:
- If the first argument is an instance of \Throwable, it extracts the error details from the exception.
- If the first argument is an array, it assumes it's a shutdown error and extracts the details accordingly.
- Otherwise, it assumes it's a standard error and extracts the details from the provided arguments.
getErrorTypeString
public getErrorTypeString({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | int |
getErrorMessage
Retrieves the error message with details about the error.
public getErrorMessage({Array})
This method constructs a string that includes the error message, the line number where the error occurred, and the file in which the error was found.
getMessage
Retrieves the error message.
public getMessage({Array})
getTrace
Get the error code.
public getTrace({Array})
cleanOutputBuffer
Cleans the output buffer by ending all active output buffering levels.
public cleanOutputBuffer({Array})
This method iterates through all active output buffering levels and ends them using ob_end_clean()
. This ensures that any buffered output is discarded and the output buffer is completely cleaned.
runner
Outputs an error message and terminates the script.
public runner({Array})
This method prints a formatted error message that includes the error number, the line number where the error occurred, the file in which the error occurred, and the error string. After printing the error message, the script is terminated with the error number as the exit status.
json
Generates a JSON response containing error details.
public json({Array})
This method constructs an error array with the following structure:
- 'ok': A boolean indicating the success status (always false).
- 'timestamp': The current timestamp.
- 'error': An array containing error details:
- 'type': The error number.
- 'status': The HTTP status code.
- 'str': The error message.
- 'class' (optional): The class where the error occurred (if display_errors is enabled).
- 'line' (optional): The line number where the error occurred (if display_errors is enabled).
- 'file' (optional): The file where the error occurred (if display_errors is enabled).
- 'trace' (optional): The debug backtrace (if display_errors is enabled).
xmlrpc
Generates an XML-RPC fault response.
public xmlrpc({Array})
This method constructs an XML structure representing an XML-RPC fault response. The response includes details about the error class, error code, status, error message, file, and line number where the error occurred.
text
Generates a detailed text response for an exception.
public text({Array})
This method constructs a formatted string containing information about the exception, including the environment, timestamp, class, error number, file, line, message, and backtrace. The backtrace includes details about each call in the stack, such as the file, line, class, and function.
html
Generates an HTML response for an error.
public html({Array})
This method creates a new Layout instance for the error view and populates it with various error details such as environment, error type, error code, error message, file, line, class, type, short message, trace, status code, and execution time. It then renders the view and returns it as an HTML response.
loadStatusCodes
Loads the status codes from the HTTP_Status.dat file and returns an array of status codes.
private loadStatusCodes({Array})
Generated by Hazaar API Doc Generator