From 3dcbdcad867bff29b6061db960eca746cbe7f38a Mon Sep 17 00:00:00 2001 From: Loek van Gool Date: Fri, 30 Dec 2022 12:32:43 +0100 Subject: [PATCH] Added more log information to Gd2.php exceptions (#1339) --- lib/Varien/Image/Adapter/Gd2.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Varien/Image/Adapter/Gd2.php b/lib/Varien/Image/Adapter/Gd2.php index 1da6514c378..aa5edefbe1a 100644 --- a/lib/Varien/Image/Adapter/Gd2.php +++ b/lib/Varien/Image/Adapter/Gd2.php @@ -227,10 +227,10 @@ private function _getCallback($callbackType, $fileType = null, $unsupportedText $fileType = $this->_fileType; } if (empty(self::$_callbacks[$fileType])) { - throw new Exception($unsupportedText); + throw new Exception("{$unsupportedText}. Type was: {$fileType}. File was: {$this->_fileName}"); } if (empty(self::$_callbacks[$fileType][$callbackType])) { - throw new Exception('Callback not found.'); + throw new Exception("Callback not found. Callbacktype was: {$callbackType}. File was: {$this->_fileName}"); } return self::$_callbacks[$fileType][$callbackType]; } @@ -245,17 +245,17 @@ private function _fillBackgroundColor(&$imageResourceTo) // fill truecolor png with alpha transparency if ($isAlpha) { if (!imagealphablending($imageResourceTo, false)) { - throw new Exception('Failed to set alpha blending for PNG image.'); + throw new Exception('Failed to set alpha blending for PNG image. File was: {$this->_fileName}'); } $transparentAlphaColor = imagecolorallocatealpha($imageResourceTo, 0, 0, 0, 127); if (false === $transparentAlphaColor) { - throw new Exception('Failed to allocate alpha transparency for PNG image.'); + throw new Exception('Failed to allocate alpha transparency for PNG image. File was: {$this->_fileName}'); } if (!imagefill($imageResourceTo, 0, 0, $transparentAlphaColor)) { - throw new Exception('Failed to fill PNG image with alpha transparency.'); + throw new Exception('Failed to fill PNG image with alpha transparency. File was: {$this->_fileName}'); } if (!imagesavealpha($imageResourceTo, true)) { - throw new Exception('Failed to save alpha transparency into PNG image.'); + throw new Exception('Failed to save alpha transparency into PNG image. File was: {$this->_fileName}'); } return $transparentAlphaColor; @@ -281,7 +281,7 @@ private function _fillBackgroundColor(&$imageResourceTo) list($r, $g, $b) = $this->_backgroundColor; $color = imagecolorallocate($imageResourceTo, $r, $g, $b); if (!imagefill($imageResourceTo, 0, 0, $color)) { - throw new Exception("Failed to fill image background with color {$r} {$g} {$b}."); + throw new Exception("Failed to fill image background with color {$r} {$g} {$b}. File was: {$this->_fileName}"); } return $color; @@ -329,7 +329,7 @@ private function _getTransparency($imageResource, $fileType, &$isAlpha = false, public function resize($frameWidth = null, $frameHeight = null) { if (empty($frameWidth) && empty($frameHeight)) { - throw new Exception('Invalid image dimensions.'); + throw new Exception('Invalid image dimensions. File was: {$this->_fileName}'); } // calculate lacking dimension