Luminova Framework

PHP Luminova: Rejected Promise Object

Last updated: 2025-12-30 09:55:30

Use Luminova’s Deferred, Fulfilled, and Rejected classes to simplify promise handling, manage pre-resolved states, and improve async logic clarity.

The Rejected class represents a promise that is already rejected with a specific error or exception.It's useful for returning an immediate failure state from a function that normally returns a promise.


Class Definition


constructor

Creates a promise that is already rejected.

public __construct(\Throwable $reason)

Parameters

ParameterTypeDescription
$reasonThrowableThe reason for the rejection, typically an exception or error.

Usage

use Luminova\Promise\Rejected;

$promise = new Rejected(new \Exception('An error occurred'));

$promise->catch(function (\Throwable $error) {
    echo "Error: " . $error->getMessage(); // Output: Error: An error occurred
});