Rework deprecated IBMDB2 exceptions

parent 2eab0857
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
namespace Doctrine\DBAL\Driver\IBMDB2; namespace Doctrine\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver\FetchUtils; 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\IBMDB2\Exception\StatementError;
use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\Statement as StatementInterface;
...@@ -522,7 +525,7 @@ class DB2Statement implements IteratorAggregate, StatementInterface, Result ...@@ -522,7 +525,7 @@ class DB2Statement implements IteratorAggregate, StatementInterface, Result
$handle = @tmpfile(); $handle = @tmpfile();
if ($handle === false) { if ($handle === false) {
throw new DB2Exception('Could not create temporary file: ' . error_get_last()['message']); throw CannotCreateTemporaryFile::new(error_get_last()['message']);
} }
return $handle; return $handle;
...@@ -537,7 +540,7 @@ class DB2Statement implements IteratorAggregate, StatementInterface, Result ...@@ -537,7 +540,7 @@ class DB2Statement implements IteratorAggregate, StatementInterface, Result
private function copyStreamToStream($source, $target): void private function copyStreamToStream($source, $target): void
{ {
if (@stream_copy_to_stream($source, $target) === false) { 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 @@ class DB2Statement implements IteratorAggregate, StatementInterface, Result ...@@ -549,7 +552,7 @@ class DB2Statement implements IteratorAggregate, StatementInterface, Result
private function writeStringToStream(string $string, $target): void private function writeStringToStream(string $string, $target): void
{ {
if (@fwrite($target, $string) === false) { 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']);
} }
} }
} }
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception;
/**
* @internal
*
* @psalm-immutable
*/
final class CannotCopyStreamToStream extends DB2Exception
{
public static function new(string $message): self
{
return new self('Could not copy source stream to temporary file: ' . $message);
}
}
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception;
/**
* @internal
*
* @psalm-immutable
*/
final class CannotCreateTemporaryFile extends DB2Exception
{
public static function new(string $message): self
{
return new self('Could not create temporary file: ' . $message);
}
}
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception;
/**
* @internal
*
* @psalm-immutable
*/
final class CannotWriteToTemporaryFile extends DB2Exception
{
public static function new(string $message): self
{
return new self('Could not write string to temporary file: ' . $message);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment