Catch icon exception when importing egg (#2299)

This commit is contained in:
Boy132
2026-04-22 13:52:31 +02:00
committed by GitHub
parent 562be98b20
commit 91c5ddb2bd
3 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ trait HasIcon
};
if (is_null($normalizedExtension)) {
throw new Exception(trans('admin/egg.import.unknown_extension'));
throw new Exception(trans('admin/egg.import.unknown_extension', ['extension' => $extension]));
}
$fileName = static::getIconStoragePath() . "/$this->uuid.$normalizedExtension";
@@ -6,6 +6,7 @@ use App\Enums\EggFormat;
use App\Exceptions\Service\InvalidFileUploadException;
use App\Models\Egg;
use App\Models\EggVariable;
use Exception;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
@@ -268,11 +269,15 @@ class EggImporterService
return;
}
$extension = strtolower($matches[1]);
$data = base64_decode($matches[2]);
try {
$extension = strtolower($matches[1]);
$data = base64_decode($matches[2]);
if ($data) {
$egg->writeIcon($extension, $data);
if ($data) {
$egg->writeIcon($extension, $data);
}
} catch (Exception $exception) {
report($exception);
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ return [
'no_local_ip' => 'Local IP Addresses are not allowed',
'unsupported_format' => 'Unsupported Format. Supported Formats: :formats',
'invalid_url' => 'The provided URL is invalid',
'unknown_extension' => 'Unknown icon extension',
'unknown_extension' => 'Unknown icon extension (:extension)',
'could_not_write' => 'Could not write icon to disk',
'icon_deleted' => 'Icon Deleted',
'no_icon' => 'No Icon Provided',