ContentException

Learn how to handle the error thrown when content cannot be fetched.

This exception is thrown when content cannot be fetched and no fallback is available. It implements CroctException.

Example

This example falls back to a default when the content cannot be fetched:

1234567891011
<?phpuse Croct\Plug\Croct;use Croct\Plug\Exception\ContentException;
$croct = Croct::fromDotenv();
try {    $content = $croct->fetchContent('home-banner');} catch (ContentException $error) {    $content = ['title' => 'Welcome to Croct!'];}