Skip to content

Commit 451f7d8

Browse files
supress json-error stack trace
1 parent 8a94ac0 commit 451f7d8

File tree

8 files changed

+10
-8
lines changed

8 files changed

+10
-8
lines changed

sonicbit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from sonicbit.client import SonicBit
44

5-
__version__ = "0.2.1"
5+
__version__ = "0.2.2"
66
__all__ = ["SonicBit"]
77

88
logging.basicConfig(

sonicbit/modules/torrent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def add_torrent(
3838
except JSONDecodeError:
3939
raise InvalidResponseError(
4040
f"Server returned invalid JSON data: {response.text}"
41-
)
41+
) from None
4242

4343
added_torrents = []
4444
if json_data["success"]:

sonicbit/types/auth_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def from_response(response: Response) -> "AuthResponse":
2222
except JSONDecodeError:
2323
raise InvalidResponseError(
2424
f"Server returned invalid JSON data: {response.text}"
25-
)
25+
) from None
2626

2727
if success_data := json_data.get("success", False):
2828
return AuthResponse(

sonicbit/types/file_list.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def from_response(client: SonicBitBase, response: Response) -> "FileList":
2222
try:
2323
json_data = response.json()
2424
except JSONDecodeError:
25-
raise InvalidResponseError("Invalid response")
25+
raise InvalidResponseError(
26+
f"Server returned invalid JSON data: {response.text}"
27+
) from None
2628

2729
result = json_data.get("result", [])
2830
items = [File.from_dict(client, item) for item in result]

sonicbit/types/storage_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def from_response(response: Response) -> "StorageDetails":
2525
except JSONDecodeError:
2626
raise InvalidResponseError(
2727
f"Server returned invalid JSON data: {response.text}"
28-
)
28+
) from None
2929

3030
if error_message := json_data.get("message"):
3131
raise SonicBitError(f"Failed to get storage details: {error_message}")

sonicbit/types/torrent/torrent_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def from_response(response: Response) -> "TorrentDetails":
2222
except JSONDecodeError:
2323
raise InvalidResponseError(
2424
f"Server returned invalid JSON data: {response.text}"
25-
)
25+
) from None
2626

2727
if error_message := json_data.get("message"):
2828
raise SonicBitError(f"Failed to get torrent details: {error_message}")

sonicbit/types/torrent/torrent_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def from_response(client: SonicBitBase, response: Response) -> "TorrentList":
2727
except JSONDecodeError:
2828
raise InvalidResponseError(
2929
f"Server returned invalid JSON data: {response.text}"
30-
)
30+
) from None
3131

3232
if error_message := json_data.get("message"):
3333
raise SonicBitError(f"Failed to get torrent list: {error_message}")

sonicbit/types/user_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def from_response(response: Response) -> "UserDetails":
4444
except JSONDecodeError:
4545
raise InvalidResponseError(
4646
f"Server returned invalid JSON data: {response.text}"
47-
)
47+
) from None
4848

4949
user_data = json_data.get("user_data")
5050
if json_data.get("message") or not user_data:

0 commit comments

Comments
 (0)