extract clone duplication logic in exceptionlisterner

See https://github.com/symfony/symfony/issues/8715