Skip to content

Commit

Permalink
fix: display Product Opener response during OFF product update if an
Browse files Browse the repository at this point in the history
error occured
  • Loading branch information
raphael0202 committed Apr 16, 2023
1 parent 7d540b5 commit 91d05d4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions robotoff/off.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from urllib.parse import urlparse

import requests
from requests.exceptions import JSONDecodeError

from robotoff import settings
from robotoff.types import ProductIdentifier, ServerType
Expand Down Expand Up @@ -419,7 +420,13 @@ def update_product(
)

r.raise_for_status()
json = r.json()
try:
json = r.json()
except JSONDecodeError as e:
logger.info(
"Error during OFF update request JSON decoding, text response: '%s'", r.text
)
raise e

status = json.get("status_verbose")

Expand Down Expand Up @@ -467,7 +474,13 @@ def update_product_v3(
)

r.raise_for_status()
json = r.json()
try:
json = r.json()
except JSONDecodeError as e:
logger.info(
"Error during OFF update request JSON decoding, text response: '%s'", r.text
)
raise e

if json.get("errors"):
raise ValueError("Errors during product update: %s", str(json["errors"]))
Expand Down

0 comments on commit 91d05d4

Please sign in to comment.