Skip to content

scrython.cards.Named() fails with Exception: HTTP Error 404: Not Found instead of scrython.base.ScryfallError #155

@mazz3rr

Description

@mazz3rr

According to the docs this:

scrython.cards.Named(exact='Nonexistent Card Name')

should trigger scrython.base.ScryfallError. Instead I get this:

Traceback (most recent call last):
  File ("/home/user/Documents/Code/PyCharm/web-scraping/_venv_3_12/lib/python3.12/site-packages"
        "/scrython/base.py"), line 190, in _fetch_raw
    with urlopen(request) as response:
         ^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.8/lib/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.8/lib/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.8/lib/python3.12/urllib/request.py", line 630,
in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.8/lib/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.8/lib/python3.12/urllib/request.py", line 492,
in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/home/user/.pyenv/versions/3.12.8/lib/python3.12/urllib/request.py", line 639,
in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File ("/home/user/Documents/Code/PyCharm/web-scraping/_venv_3_12/lib/python3.12/site-packages"
        "/scrython/base.py"), line 122, in __init__
    self._fetch(**kwargs)
  File ("/home/user/Documents/Code/PyCharm/web-scraping/_venv_3_12/lib/python3.12/site-packages"
        "/scrython/base.py"), line 222, in _fetch
    self._scryfall_data = self._fetch_raw(url, cache_key=cache_key, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ("/home/user/Documents/Code/PyCharm/web-scraping/_venv_3_12/lib/python3.12/site-packages"
        "/scrython/base.py"), line 203, in _fetch_raw
    raise Exception(f"{exc}: {request.get_full_url()}") from exc
Exception: HTTP Error 404: Not Found: https://api.scryfall.com/cards/named?format=json&face=&version=&pretty=&exact=Nonexistent+Card+Name

I'm on Scrython 2.0.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions