NotFoundException
extends HTTPException
in package
Exception for missing resources (HTTP 404).
Thrown when an API endpoint or resource cannot be found. Always uses HTTP 404 status code regardless of constructor parameters.
Usage:
if (!$user) {
NotFoundException::throw(msg: 'user_not_found', more: ['id' => $id]);
}
// Or raise directly:
throw new NotFoundException('post_not_found');
Tags
Table of Contents
Properties
- $more : mixed
Methods
- __construct() : mixed
- Initialize a 404 exception.
- throw() : never
- Throw an exception with flexible named arguments.
Properties
$more read-only
public
mixed
$more
= null
Methods
__construct()
Initialize a 404 exception.
public
__construct([string $msg = 'not_found' ][, int $_code = 404 ][, Throwable|null $parent = null ][, mixed $more = null ]) : mixed
Parameters
- $msg : string = 'not_found'
-
Error message. Defaults to 'not_found'.
- $_code : int = 404
-
Ignored; always uses 404. Present for API compatibility.
- $parent : Throwable|null = null
-
Previous exception for chaining.
- $more : mixed = null
-
Structured error metadata.
throw()
Throw an exception with flexible named arguments.
public
static throw([int|null $code = null ][, string|null $msg = null ][, Throwable|null $parent = null ][, mixed $more = null ]) : never
Static factory method for elegant exception creation. Only non-null arguments are included in the constructor call, allowing clean fluent syntax without positional confusion or needing to pass null for skipped parameters.
Parameters
- $code : int|null = null
-
HTTP status code.
- $msg : string|null = null
-
Error message.
- $parent : Throwable|null = null
-
Previous exception for chaining.
- $more : mixed = null
-
Structured error metadata.
Tags
Return values
never —Always throws the constructed exception.