phpEZ v0.1.3

DataException extends HTTPException
in package

Base exception for database operation failures.

Used for general data integrity and operation errors. Extends HTTPException with a 500 status code by default (indicating server error).

Tags
see
DuplicateException

For constraint violations.

subpackage

db

Table of Contents

Properties

$more  : mixed

Methods

__construct()  : mixed
Initialize a database exception.
throw()  : never
Throw an exception with flexible named arguments.

Properties

Methods

__construct()

Initialize a database exception.

public __construct([string|null $msg = null ][, int|null $code = null ][, Exception|null $parent = null ][, mixed $more = null ]) : mixed
Parameters
$msg : string|null = null

Error message. Defaults to 'duplicate'.

$code : int|null = null

HTTP status code. Defaults to 500.

$parent : Exception|null = null

Previous exception for chaining.

$more : mixed = null

Additional context data for debugging.

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
example
// Minimal
HTTPException::throw(code: 400, msg: 'bad_request');

// With metadata
HTTPException::throw(
  code: 400,
  msg: 'validation_error',
  more: ['field' => 'email', 'reason' => 'already_exists']
);

// With exception chaining
try {
  $pdo->query($sql);
} catch (PDOException $e) {
  HTTPException::throw(code: 500, msg: 'database_error', parent: $e);
}
Return values
never

Always throws the constructed exception.

On this page

Search results