From 442524a1c963c03c76f5ceef79cc06239321fded Mon Sep 17 00:00:00 2001 From: Loek van Gool Date: Fri, 11 Dec 2020 16:44:45 +0100 Subject: [PATCH] Adding useful feedback to Gd2.php exceptions --- 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 763eadda300..ee2d5be8766 100644 --- a/lib/Varien/Image/Adapter/Gd2.php +++ b/lib/Varien/Image/Adapter/Gd2.php @@ -238,10 +238,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]; } @@ -257,17 +257,17 @@ private function _fillBackgroundColor(&$imageResourceTo) 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; @@ -296,7 +296,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; @@ -347,7 +347,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