Rethrow Loses Stack Trace (ARCH7154)
Ce contenu n’est pas encore disponible dans votre langue.
Key php.logging.rethrow-without-previous · Severity warning · Category logging
Throwing a new exception inside a handler without passing the original as the previous argument destroys the root cause and stack trace.
Incorrect
Section titled “Incorrect”<?phptry { $this->client->request($url);} catch (TransportException $e) { throw new ServiceException('Upstream call failed');}Correct
Section titled “Correct”<?phptry { $this->client->request($url);} catch (TransportException $e) { throw new ServiceException('Upstream call failed', 0, $e);}Pass the original exception as the previous (third) argument when throwing the new one.