Class: SmartExceptionCollection

Class for extended exception collection used in the SmartFactory library. It allows to collect many errors and report them at once.

Extends

\Exception

Authors

Oleg Schildt

Package

Source code

 

Properties
protected

Internal variable for storing the single errors.

Methods
public

Stores the error to be reported.

public

Returns the array of errors if any have been stored.

public

Throws itself if any error has been collected.


Property: SmartExceptionCollection::$errors

protected array $errors = [];

Internal variable for storing the single errors.

Type

array

Authors

Oleg Schildt

Source code


Method: SmartExceptionCollection::addError()

public function addError(string $message, array $details = [], string $related_element = "", string $code = "", string $technical_info = "", string $file = "", string $line = "" ) : void;

Stores the error to be reported.

Parameters

Name Pass type Value type Default value Description
$message by value string

The error message to be reported.

$details by value array []

The details might be useful if the message translations are provided on the client, not on the server, and the message should contain some details that may vary from case to case. In that case, the servers return the message id instead of final text and the details, the client uses the message id, gets the final translated text and substitutes the parameters through the details.

$related_element by value string ""

The error element associated with the error.

$code by value string ""

The error code to be reported.

$technical_info by value string ""

The technical information for the error. Displaying of this part might be controlled over an option "debug_mode".

$file by value string ""

The source file where the error occurred. Per default, the file where the adding error called.

$line by value string ""

The source file line where the error occurred. Per default, the file line where the adding error called.

Returns

void

Authors

Oleg Schildt

Source code


Method: SmartExceptionCollection::getErrors()

public function getErrors(): array;

Returns the array of errors if any have been stored.

Returns

array

Returns the array of errors if any have been stored.

Authors

Oleg Schildt

Source code


Method: SmartExceptionCollection::throwIfErrors()

public function throwIfErrors(): void;

Throws itself if any error has been collected.

Returns

void

Throws

\SmartFactory\SmartExceptionCollection

Throws itself if there are errors.

Authors

Oleg Schildt

Source code