Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 7651a83

Browse files
committed
Fix exception message not suscriptable
1 parent 029ac70 commit 7651a83

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "facturapi-python"
7-
version = "0.1.2"
7+
version = "0.1.3"
88
authors = [{ name = "TI Sin Problemas", email = "pypi@tisinproblemas.com" }]
99
description = "Unofficial Facturapi.io Python client"
1010
readme = "README.md"

src/facturapi/http.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,18 @@ def _execute_request(
106106
raise FacturapiException(message) from error
107107

108108
self.last_status = response.status_code
109+
error_status_codes = [
110+
self.STATUS_BAD_REQUEST,
111+
self.STATUS_INTERNAL_SERVER_ERROR,
112+
]
109113

110-
if response.status_code == self.STATUS_BAD_REQUEST:
111-
raise FacturapiException(response["message"])
114+
if response.status_code in error_status_codes:
115+
json_response = response.json()
116+
raise FacturapiException(json_response["message"])
112117

113118
if response.status_code == self.STATUS_NOT_AUTHENTICATED:
114119
raise FacturapiException("Wrong API KEY")
115120

116-
if response.status_code == self.STATUS_INTERNAL_SERVER_ERROR:
117-
raise FacturapiException(response["message"])
118-
119121
return response
120122

121123
def _get_download_file_url(self, file_format: str, object_id: str):

0 commit comments

Comments
 (0)