Refactor error handling in Node class
- Updated the `Node` class to use `response.raise_for_status()` for improved error handling, replacing the previous manual check for a 500 status code. This change simplifies the error management process when fetching node data.
This commit is contained in:
@@ -18,8 +18,7 @@ class Node:
|
|||||||
if not url.endswith(".json"):
|
if not url.endswith(".json"):
|
||||||
url += ".json"
|
url += ".json"
|
||||||
response = self._session.get(url)
|
response = self._session.get(url)
|
||||||
if response.status_code == 500:
|
response.raise_for_status()
|
||||||
raise ValueError(f"page {url} not found")
|
|
||||||
return NodeView(
|
return NodeView(
|
||||||
session=self._session, base_url=self._base_url, data=response.json()
|
session=self._session, base_url=self._base_url, data=response.json()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user