From 569ca3956a773d814de10f72a9c1f7b487ba8e0a Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 23 Jun 2020 18:12:58 -0700 Subject: [PATCH] Rework deprecated IBMDB2 exceptions --- .../DBAL/Driver/IBMDB2/DB2Statement.php | 9 ++++++--- .../Exception/CannotCopyStreamToStream.php | 20 +++++++++++++++++++ .../Exception/CannotCreateTemporaryFile.php | 20 +++++++++++++++++++ .../Exception/CannotWriteToTemporaryFile.php | 20 +++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index d65e04c91e0..71954994e53 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -3,6 +3,9 @@ namespace Doctrine\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCopyStreamToStream; +use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCreateTemporaryFile; +use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotWriteToTemporaryFile; use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement as StatementInterface; @@ -522,7 +525,7 @@ private function createTemporaryFile() $handle = @tmpfile(); if ($handle === false) { - throw new DB2Exception('Could not create temporary file: ' . error_get_last()['message']); + throw CannotCreateTemporaryFile::new(error_get_last()['message']); } return $handle; @@ -537,7 +540,7 @@ private function createTemporaryFile() private function copyStreamToStream($source, $target): void { if (@stream_copy_to_stream($source, $target) === false) { - throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']); + throw CannotCopyStreamToStream::new(error_get_last()['message']); } } @@ -549,7 +552,7 @@ private function copyStreamToStream($source, $target): void private function writeStringToStream(string $string, $target): void { if (@fwrite($target, $string) === false) { - throw new DB2Exception('Could not write string to temporary file: ' . error_get_last()['message']); + throw CannotWriteToTemporaryFile::new(error_get_last()['message']); } } } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php new file mode 100644 index 00000000000..8223a92d660 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php @@ -0,0 +1,20 @@ +