diff --git a/vendor/magento/module-shipping/Model/Shipping/LabelGenerator.php b/vendor/magento/module-shipping/Model/Shipping/LabelGenerator.php index dad67505b540c..bccc3f5c04399 100644 --- a/vendor/magento/module-shipping/Model/Shipping/LabelGenerator.php +++ b/vendor/magento/module-shipping/Model/Shipping/LabelGenerator.php @@ -1,16 +1,17 @@ getOrder(); $carrier = $this->carrierFactory->create($order->getShippingMethod(true)->getCarrierCode()); @@ -76,7 +79,8 @@ public function create(\Magento\Sales\Model\Order\Shipment $shipment, RequestInt $shipment->setPackages($request->getParam('packages')); $response = $this->labelFactory->create()->requestToShipment($shipment); if ($response->hasErrors()) { - throw new \Magento\Framework\Exception\LocalizedException(__($response->getErrors())); + $firstError = $response->getErrors()[0]; + throw new \Magento\Framework\Exception\LocalizedException(__($firstError)); } if (!$response->hasInfo()) { throw new \Magento\Framework\Exception\LocalizedException(__('Response info is not exist.')); @@ -104,7 +108,9 @@ public function create(\Magento\Sales\Model\Order\Shipment $shipment, RequestInt } /** - * @param \Magento\Sales\Model\Order\Shipment $shipment + * Adds tracking number to a shipment + * + * @param Shipment $shipment * @param array $trackingNumbers * @param string $carrierCode * @param string $carrierTitle @@ -112,7 +118,7 @@ public function create(\Magento\Sales\Model\Order\Shipment $shipment, RequestInt * @return void */ private function addTrackingNumbersToShipment( - \Magento\Sales\Model\Order\Shipment $shipment, + Shipment $shipment, $trackingNumbers, $carrierCode, $carrierTitle @@ -168,9 +174,11 @@ public function createPdfPageFromImageString($imageString) $directory = $this->filesystem->getDirectoryWrite( DirectoryList::TMP ); - $directory->create(); - $image = @imagecreatefromstring($imageString); - if (!$image) { + + try { + $directory->create(); + $image = imagecreatefromstring($imageString); + } catch (\Exception $e) { return false; }