Skip to content

Commit

Permalink
catch CswErrors in reimport_batch()
Browse files Browse the repository at this point in the history
  • Loading branch information
knudmoeller committed Jan 31, 2024
1 parent c4096b9 commit 29c2f8b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Development

- Catch Exceptions raised by a failing `text_traceback()` during error handling for CSW communication.
- Improved Exception handling in several places.
- More F-Strings.

## [1.4.1](https://github.com/berlinonline/ckanext-fisbroker/releases/tag/1.4.1)
Expand Down
5 changes: 2 additions & 3 deletions ckanext/fisbroker/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from ckan.model import Package, Session
from ckan.plugins import toolkit

from owslib.csw import CatalogueServiceWeb

from requests.exceptions import RequestException, ConnectionError

from ckanext.harvest.model import (
Expand All @@ -27,6 +25,7 @@
HarvestObjectExtra,
HarvestGatherError
)
from ckanext.spatial.lib.csw_client import CswError

from ckanext.fisbroker import HARVESTER_ID
from ckanext.fisbroker.csw_client import CswService
Expand Down Expand Up @@ -196,7 +195,7 @@ def reimport_batch(package_ids, context):
err.save()
raise NotFoundInFisbrokerError(package_id, fb_guid)

except (RequestException, ProtocolError, ConnectionError, AttributeError) as error:
except (RequestException, ProtocolError, ConnectionError, AttributeError, CswError) as error:
raise NoConnectionError(package_id, harvester_url, str(error.__class__.__name__))
finally:
# finish harvest job, both successfully and unsuccessfully
Expand Down
2 changes: 1 addition & 1 deletion ckanext/fisbroker/csw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def getrecordbyid(self, ids=[], esn="full", outputschema="gmd", retries=3, wait_
try:
err = f"Error getting record by id: {text_traceback()}"
except Exception as e2:
err = f"Error getting record by id, text_traceback() failed ({e2})"
err = f"Error getting record by id, text_traceback() failed ({e})"
if attempt < retries:
log.info(err)
log.info(f"waiting {wait_time} seconds...")
Expand Down

0 comments on commit 29c2f8b

Please sign in to comment.