1.2.1073. Set Chaining Exception

Chaining exception allows rethrowing a caught exception with a new one. The previous exception is added to the new exception, for later reference.

For that, the constructor of the chaining exception must relay the previous one to the parent constructor.

<?php

//
class myChainingException{
     function __construct($message, $code = 0, \Throwable $exception = null) {
             // This exception can be chained
             parent::__construct($message, $code, $exception);
     }
}

// No chaining possible
class myException{
     function __construct($message) {
             // This exception can't chain anything
             parent::__construct($message);
     }
}

?>

1.2.1073.1. Suggestions

  • Add the default values to allow chaining

1.2.1073.2. Specs

Short name

Exceptions/SetChainingException

Rulesets

All, Changed Behavior, Class Review

Exakat since

2.5.0

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

chaining-exception

Available in

Entreprise Edition, Exakat Cloud