Heratio Framework API Reference

ServiceException extends Exception
in package

Service Layer Exception for business logic errors.

Use this for recoverable errors in service classes.

Table of Contents

Methods

__construct()  : mixed
badRequest()  : self
conflict()  : self
forbidden()  : self
getContext()  : array<string|int, mixed>
getStatusCode()  : int
getUserMessage()  : string
Get user-friendly message (safe to display).
internal()  : self
notFound()  : self
toArray()  : array<string|int, mixed>
Convert to array for JSON response.
unauthorized()  : self
validationFailed()  : self

Methods

__construct()

public __construct([string $message = '' ][, int $statusCode = 500 ][, array<string|int, mixed> $context = [] ][, string|null $userMessage = null ][, Throwable|null $previous = null ]) : mixed
Parameters
$message : string = ''
$statusCode : int = 500
$context : array<string|int, mixed> = []
$userMessage : string|null = null
$previous : Throwable|null = null

badRequest()

public static badRequest(string $message) : self
Parameters
$message : string
Return values
self

conflict()

public static conflict(string $message) : self
Parameters
$message : string
Return values
self

forbidden()

public static forbidden([string $reason = 'Permission denied' ]) : self
Parameters
$reason : string = 'Permission denied'
Return values
self

getContext()

public getContext() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUserMessage()

Get user-friendly message (safe to display).

public getUserMessage() : string
Return values
string

internal()

public static internal(string $message[, Throwable|null $previous = null ]) : self
Parameters
$message : string
$previous : Throwable|null = null
Return values
self

notFound()

public static notFound(string $resource[, mixed $id = null ]) : self
Parameters
$resource : string
$id : mixed = null
Return values
self

toArray()

Convert to array for JSON response.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

unauthorized()

public static unauthorized([string $reason = 'Authentication required' ]) : self
Parameters
$reason : string = 'Authentication required'
Return values
self

validationFailed()

public static validationFailed(array<string|int, mixed> $errors) : self
Parameters
$errors : array<string|int, mixed>
Return values
self

        
On this page

Search results