stripSecret($actualException->getMessage(), $secret), $actualException->getCode() ); } protected function stripSecret(string $message, string $secret): string { return str_replace($secret, '****', $message); } public function __toString(): string { return $this->stripSecret($this->actualException->__toString(), $this->secret); } }