Skip to content

Internals Exception ExceptionBase

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

exception\ExceptionBase

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/exception/ExceptionBase.php · Snapshot 8411f4287706.

Framework exception wrappers retain the previous Throwable and attach the current context when available. Installed boot registers CLI/web renderers.

Imports and dependencies

use context\Context;
use context\events\GetContextEvent;

ExceptionBase

Declaration and architectural role

abstract class ExceptionBase extends \Exception

Constants, enum cases, traits and properties

Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.

Member Declaration Purpose or source contract
$context public Context $context; Used by __construct().
$event private GetContextEvent $event; Used by __construct().
Constructor-promoted public function __construct(?\Throwable $previous = null) Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct(?\Throwable $previous = null)
buildMessage abstract public function buildMessage(): string

__construct

Source line 13

public function __construct(?\Throwable $previous = null)

Parameters

Parameter Type, modifiers and default Purpose
$previous ?\Throwable $previous = null Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->event, $this->context.

Implementation, validation guards and interaction order
public function __construct(?\Throwable $previous = null)
    {
        global $eventDispatcher;
        $this->event = new GetContextEvent();
        $this->context = new Context("", "System", "/");
        $this->event->setContext($this->context);
        if ($eventDispatcher instanceof \event\EventDispatcher) $eventDispatcher->dispatch($this->event);
        $this->context = $this->event->getContext();

        $message = $this->buildMessage();
        if ($previous) {
            $message .= "\nCaused by: " . $previous->getMessage();
        }

        parent::__construct($message, 0, $previous);
    }

buildMessage

Source line 30

abstract public function buildMessage(): string;

Contract only: implementations supply the behavior. Parameter and return types are enforced by PHP; caller and implementation constraints follow the subsystem overview.

Related types

Clone this wiki locally