Skip to content

Commit 3e32476

Browse files
committed
error handling
1 parent e91eb15 commit 3e32476

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/Utilities/ImageAsset.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Assets\Error\FileNotFoundException;
77
use Assets\Error\FilterNotFoundException;
8+
use Assets\Error\ModificationFailedException;
89
use Assets\Error\UnkownErrorException;
910
use Assets\ImageCreation\FilterInterface;
1011
use Assets\ImageCreation\ImageInterface;
@@ -459,12 +460,35 @@ private function applyModifications(ImageInterface $image, ImageManagerInterface
459460
);
460461
}
461462

462-
$image = $filterClassName::create($manager, ...$params)->applyFilter($image);
463+
try {
464+
$image = $filterClassName::create($manager, ...$params)->applyFilter($image);
465+
} catch (\Throwable $throwable) {
466+
throw new ModificationFailedException(
467+
sprintf(
468+
'Unable to apply filter `%s` with params %s.',
469+
$filterClassName,
470+
var_export($params, true),
471+
),
472+
previous: $throwable,
473+
);
474+
}
463475
continue;
464476
}
465477

466478
$params = is_array($params) ? $params : [$params];
467-
$image->modify($method, $params);
479+
480+
try {
481+
$image->modify($method, $params);
482+
} catch (\Throwable $throwable) {
483+
throw new ModificationFailedException(
484+
sprintf(
485+
'Unable to modify image with method `%s` and params %s.',
486+
$method,
487+
var_export($params, true),
488+
),
489+
previous: $throwable,
490+
);
491+
}
468492
}
469493

470494
return $image;

0 commit comments

Comments
 (0)