shweshi / OpenGraph

A Laravel package to fetch Open Graph data of a website.
https://opengraph.shashi.dev
MIT License
154 stars 29 forks source link

throwing an exception when the url returns 404 -breaking test. #67

Closed jayenne closed 3 years ago

jayenne commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior: Run a test from cli that calls... $data = OpenGraph::fetch($url, true); // where url returns a 404 error. See error: shweshi\OpenGraph\Exceptions\FetchException. The requested URL returned error: 404 Not Found

Expected behavior I would have expected the error to have been failed gracefully, returning the 404 message to the calling method.

Desktop (please complete the following information):

Additional context I'm actually calling it with... but still not getting past the fetch error thrown.

try {
            $data = OpenGraph::fetch($url, true);
        } catch (shweshi\OpenGraph\Exceptions\FetchException $e) {
            $message = $e->getMessage();
            $data = $e->getData();
        }
RageZBla commented 3 years ago

Hello, may I work on this issue?