Skip to content

Commit 7f78cab

Browse files
committed
hint about the http client when icon not found
1 parent e653f48 commit 7f78cab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Icons/src/Registry/ChainIconRegistry.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\UX\Icons\Registry;
1313

14+
use Symfony\Component\HttpClient\HttpClient;
1415
use Symfony\UX\Icons\Exception\IconNotFoundException;
1516
use Symfony\UX\Icons\Icon;
1617
use Symfony\UX\Icons\IconRegistryInterface;
@@ -38,6 +39,11 @@ public function get(string $name): Icon
3839
}
3940
}
4041

41-
throw new IconNotFoundException(\sprintf('Icon "%s" not found.', $name));
42+
$exceptionExtra = '';
43+
if (str_contains($name, ':') && !class_exists(HttpClient::class)) {
44+
$exceptionExtra = ' If you want the on-demand registry to fetch the icon from iconfiy, you need to install "symfony/http-client".';
45+
}
46+
47+
throw new IconNotFoundException(\sprintf('Icon "%s" not found.%s', $name, $exceptionExtra));
4248
}
4349
}

0 commit comments

Comments
 (0)