Properties

$ob_level

$ob_level : integer

Nesting level of the output buffering mechanism

Type

integer

$viewPath

$viewPath : string

The path to the directory containing the cli and html error view directories.

Type

string

$config

$config : \Config\Exceptions

Config for debug exceptions.

Type

\Config\Exceptions

$codes

$codes : array

Allows child classes to override the status code that is used in their API.

Type

array

Methods

initialize()

initialize() 

Responsible for registering the error, exception and shutdown handling of our application.

exceptionHandler()

exceptionHandler(\Throwable  $exception) 

错误日志增加最后执行的sql语句

Parameters

\Throwable $exception

errorHandler()

errorHandler(integer  $severity, string  $message, string|null  $file = null, integer|null  $line = null, null  $context = null) 

排除部分错误提示

This seems to be primarily when a user triggers it with trigger_error().

Parameters

integer $severity
string $message
string|null $file
integer|null $line
null $context

shutdownHandler()

shutdownHandler() 

Checks to see if any errors have happened during shutdown that need to be caught and handle them.

cleanPath()

cleanPath(string  $file) : string

Clean Path

This makes nicer looking paths for the error output.

Parameters

string $file

Returns

string

describeMemory()

describeMemory(  $bytes) : string

Describes memory usage in real-world units. Intended for use with memory_get_usage, etc.

Parameters

$bytes

Returns

string

highlightFile()

highlightFile(string  $file, integer  $lineNumber, integer  $lines = 15) : boolean|string

Creates a syntax-highlighted version of a PHP file.

Parameters

string $file
integer $lineNumber
integer $lines

Returns

boolean|string

respond()

respond(array|string|null  $data = null, integer  $status = null, string  $message = '') : mixed

Provides a single, simple method to return an API response, formatted to match the requested format, with proper content-type and status code.

Parameters

array|string|null $data
integer $status
string $message

Returns

mixed

fail()

fail(string|array  $messages, integer|null  $status = 400, string|null  $code = null, string  $customMessage = '') : mixed

Used for generic failures that no custom methods exist for.

Parameters

string|array $messages
integer|null $status

HTTP status code

string|null $code

Custom, API-specific, error code

string $customMessage

Returns

mixed

respondCreated()

respondCreated(mixed  $data = null, string  $message = '') : mixed

Used after successfully creating a new resource.

Parameters

mixed $data

Data.

string $message

Message.

Returns

mixed

respondDeleted()

respondDeleted(mixed  $data = null, string  $message = '') : mixed

Used after a resource has been successfully deleted.

Parameters

mixed $data

Data.

string $message

Message.

Returns

mixed

respondNoContent()

respondNoContent(string  $message = 'No Content') : mixed

Used after a command has been successfully executed but there is no meaningful reply to send back to the client.

Parameters

string $message

Message.

Returns

mixed

failUnauthorized()

failUnauthorized(string  $description = 'Unauthorized', string  $code = null, string  $message = '') : mixed

Used when the client is either didn't send authorization information, or had bad authorization credentials. User is encouraged to try again with the proper information.

Parameters

string $description
string $code
string $message

Returns

mixed

failForbidden()

failForbidden(string  $description = 'Forbidden', string  $code = null, string  $message = '') : mixed

Used when access is always denied to this resource and no amount of trying again will help.

Parameters

string $description
string $code
string $message

Returns

mixed

failNotFound()

failNotFound(string  $description = 'Not Found', string  $code = null, string  $message = '') : mixed

Used when a specified resource cannot be found.

Parameters

string $description
string $code
string $message

Returns

mixed

failValidationError()

failValidationError(string  $description = 'Bad Request', string  $code = null, string  $message = '') : mixed

Used when the data provided by the client cannot be validated.

Parameters

string $description
string $code
string $message

Returns

mixed

failResourceExists()

failResourceExists(string  $description = 'Conflict', string  $code = null, string  $message = '') : mixed

Use when trying to create a new resource and it already exists.

Parameters

string $description
string $code
string $message

Returns

mixed

failResourceGone()

failResourceGone(string  $description = 'Gone', string  $code = null, string  $message = '') : mixed

Use when a resource was previously deleted. This is different than Not Found, because here we know the data previously existed, but is now gone, where Not Found means we simply cannot find any information about it.

Parameters

string $description
string $code
string $message

Returns

mixed

failTooManyRequests()

failTooManyRequests(string  $description = 'Too Many Requests', string  $code = null, string  $message = '') : mixed

Used when the user has made too many requests for the resource recently.

Parameters

string $description
string $code
string $message

Returns

mixed

failServerError()

failServerError(string  $description = 'Internal Server Error', string|null  $code = null, string  $message = '') : \CodeIgniter\HTTP\Response

Used when there is a server error.

Parameters

string $description

The error message to show the user.

string|null $code

A custom, API-specific, error code.

string $message

A custom "reason" message to return.

Returns

\CodeIgniter\HTTP\Response

The value of the Response's send() method.

determineView()

determineView(\Throwable  $exception, string  $template_path) : string

Determines the view to display based on the exception thrown, whether an HTTP or CLI request, etc.

Parameters

\Throwable $exception
string $template_path

Returns

string —

The path and filename of the view file to use

render()

render(\Throwable  $exception, \Phpcmf\Extend\int  $statusCode) 

错误输出结果

Parameters

\Throwable $exception
\Phpcmf\Extend\int $statusCode

collectVars()

collectVars(\Throwable  $exception, integer  $statusCode) : array

Gathers the variables that will be made available to the view.

Parameters

\Throwable $exception
integer $statusCode

Returns

array

determineCodes()

determineCodes(\Throwable  $exception) : array

Determines the HTTP status code and the exit status code for this request.

Parameters

\Throwable $exception

Returns

array

format()

format(string|array|null  $data = null) : string|null

Handles formatting a response. Currently makes some heavy assumptions and needs updating! :)

Parameters

string|array|null $data

Returns

string|null

_save_error_file()

_save_error_file(  $statusCode,   $title,   $file,   $line,   $message,   $is_kz) 

Parameters

$statusCode
$title
$file
$line
$message
$is_kz