Skip to content

Commit

Permalink
fix: exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MehmedGIT committed Aug 14, 2024
1 parent bb3007d commit ff4243f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/ocrd_network/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Optional
from ocrd_utils import config, getLogger, LOG_FORMAT
from .client_utils import (
get_ps_deployed_processors,
Expand All @@ -16,7 +17,7 @@
class Client:
def __init__(
self,
server_addr_processing: str,
server_addr_processing: Optional[str],
timeout: int = config.OCRD_NETWORK_CLIENT_POLLING_TIMEOUT,
wait: int = config.OCRD_NETWORK_CLIENT_POLLING_SLEEP
):
Expand Down
9 changes: 4 additions & 5 deletions src/ocrd_network/server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ def request_processor_server_tool_json(logger: Logger, processor_server_base_url
urljoin(base=processor_server_base_url, url="info"),
headers={"Content-Type": "application/json"}
)
if response.status_code != 200:
message = f"Failed to retrieve tool json from: {processor_server_base_url}, code: {response.status_code}"
raise_http_exception(logger, status.HTTP_404_NOT_FOUND, message)
return response.json()
except Exception as error:
message = f"Failed to retrieve ocrd tool json from: {processor_server_base_url}"
raise_http_exception(logger, status.HTTP_404_NOT_FOUND, message, error)

if response.status_code != 200:
message = f"Failed to retrieve tool json from: {processor_server_base_url}, code: {response.status_code}"
raise_http_exception(logger, status.HTTP_404_NOT_FOUND, message)
return response.json()

async def forward_job_to_processor_server(
logger: Logger, job_input: PYJobInput, processor_server_base_url: str
Expand Down

0 comments on commit ff4243f

Please sign in to comment.