This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Timur Shakirov
Timur Shakirov

I use

$url = "here is the link";
$file = new \System\Models\File();
if($file->fromUrl($url)) // error here
{
    $post->featured_images()->save($file);
}

Error:

In File.php line 175:
Error getting file "here is the link", error code: 400

How can I handle the error to keep the script running? System\Models\File

Last updated

mjauvin
mjauvin
try {
    $file->fromUrl($url);
} catch (\Exception $ex) {
    //handle exception here
}
Timur Shakirov
Timur Shakirov

mjauvin said:

try {
   $file->fromUrl($url);
} catch (\Exception $ex) {
   //handle exception here
}

OK, Thanks! Before your answer, I already tried this construction, but nothing worked. The point is in the "\" before the Exception.

mjauvin
mjauvin

Yes, either use "\" in front or a use Exception; at the start of your php file.

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.