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"):
|
||||
url += ".json"
|
||||
response = self._session.get(url)
|
||||
if response.status_code == 500:
|
||||
raise ValueError(f"page {url} not found")
|
||||
response.raise_for_status()
|
||||
return NodeView(
|
||||
session=self._session, base_url=self._base_url, data=response.json()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user