Naify\Router\Exception\RouteException クラス
extends
RuntimeException
ルーティング例外 — ルーティング〜コントローラ層のエラー
ルートが見つからない(404)、メソッド不一致(405)、 アクセス拒否(403)など、HTTP ステータスコードを伴うエラーを表現する。 コントローラ内から意図的に throw することもできる。
Application::handle() で catch され、ルーティングレベルの エラーハンドラに委譲される。
使用例
// Router 内部(ルート未発見)
throw new RouteException(404, 'Route not found: /hoge/test');
// コントローラ内(意図的なエラー)
throw new RouteException(403, 'Access denied');
throw new RouteException(400, 'Invalid parameter: id');
プロパティ
| 名前 | 型 | 説明 |
|---|---|---|
private
$statusCode
|
int |
HTTP ステータスコード |
private
$context
|
?RequestContext |
エラー発生時のリクエストコンテキスト |
メソッド
| メソッド | 説明 |
|---|---|
public
override
__construct(int $statusCode, string $message = , ?RequestContext $context, ?Throwable $previous):
|
ステータスコード付きのルーティング例外を生成する |
public
getStatusCode(): int
|
HTTP ステータスコードを取得する 8.4 → property hooks |
public
getRequestContext(): ?RequestContext
|
リクエストコンテキストを取得する 8.4 → property hooks |
継承プロパティ
| 名前 | 型 | 説明 | 継承元 |
|---|---|---|---|
protected
$message
|
mixed |
Exception | |
protected
$code
|
mixed |
Exception | |
protected
$file
|
string |
Exception | |
protected
$line
|
int |
Exception |
継承メソッド
| メソッド | 説明 | 継承元 |
|---|---|---|
public
getMessage(): string
|
Exception | |
public
getCode():
|
Exception | |
public
getFile(): string
|
Exception | |
public
getLine(): int
|
Exception | |
public
getTrace(): array
|
Exception | |
public
getPrevious(): ?Throwable
|
Exception | |
public
getTraceAsString(): string
|
Exception |