ErrorTask
Base class for WebSocket tasks.
Tasks get typed access to the WebSocket console, router, and dispatcher through PhalconKit injectable properties. Concrete tasks should implement action methods such as listenAction().
- Full name:
\PhalconKit\Modules\Ws\Tasks\ErrorTask - Parent class:
\PhalconKit\Modules\Ws\Task
Methods
setStatusCode
Set the status code for the response. Immediately throw a WsException.
public setStatusCode(int $code = 500, string|null $message = null): \Phalcon\Http\ResponseInterface
Parameters:
| Parameter | Type | Description |
|---|---|---|
$code | int | The status code to set. Defaults to 500 if not provided. |
$message | string|null | The optional message to associate with the status code. |
Throws:
If an error occurs while setting the status code. - WsException
Inherited methods
resetRequestState
Clear all request-scoped state in a long-running worker.
public resetRequestState(): void
One Swoole worker serves many clients with the same container, so state from one callback must not reach the next: write-connection pinning, the identity manager's cached claim and users, the model ACL role cache, and the Blameable parent link. The built-in abstract task invokes this for open, message, close, HTTP request, and pipe-message callbacks; call it before custom callbacks that authenticate or perform model operations.
resetConnectionState
Clear request-scoped model connection state in a long-running worker.
public resetConnectionState(): void
This is part of resetRequestState(), which callbacks should call instead so identity and model ACL caches are reset too.
errorAction
Render a generic error using an explicit or already-selected status.
public errorAction(?int $code = null, ?string $message = null): void
Dispatcher listeners can set the shared response status before forwarding here. Direct callers may still provide a status and optional reason phrase; otherwise the action falls back to HTTP 500.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$code | ?int | |
$message | ?string |
badRequestAction
Http Status Code 400 bad-request
public badRequestAction(): void
unauthorizedAction
Http Status Code 401 unauthorized
public unauthorizedAction(): void
forbiddenAction
Http Status Code 403 forbidden
public forbiddenAction(): void
notFoundAction
Http Status Code 404 not-found
public notFoundAction(): void
fatalAction
Http Status Code 500 fatal
public fatalAction(): void
maintenanceAction
Http Status Code 503 maintenance
public maintenanceAction(): void