Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error handling #6

Merged
merged 5 commits into from
Jun 7, 2021
Merged

Improved error handling #6

merged 5 commits into from
Jun 7, 2021

Conversation

demiankatz
Copy link
Member

This PR improves error handling in the harvester in a few ways:

  • A single failed harvest does not prevent other harvests from taking place
  • A noRecordsMatch error is no longer treated as fatal
  • Test coverage is improved

@demiankatz
Copy link
Member Author

@EreMaijala, I suspect that you do not use this tool, so if you prefer for me to find a different reviewer, just let me know! :-)

Copy link
Contributor

@EreMaijala EreMaijala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demiankatz Tested and works fine. I left one comment about the code style in catching the exceptions. Feel free to ignore if you disagree, but I'd say it would be cleaner to do like this:

try {
} catch (OaiException $e) {
} catch (\Exception $e) {
}

@@ -345,8 +346,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$this->harvestSingleRepository($input, $output, $target, $settings);
} catch (\Exception $e) {
$this->writeLine($e->getMessage());
return 1;
if ($e instanceof OaiException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner to catch OaiException in its own catch block. But one could argue that noRecordsMatch shouldn't even cause an exception since it can happen during normal operation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's strange to treat noRecordsMatch as an error, but since the OAI-PMH protocol treats it as such, I think it's okay for us to do the same for the sake of consistency.

Regarding a separate catch block for the OaiException, I did consider that, but since our special case relies not just on the exception class, but also on a specific code, I don't think I can do that without having to duplicate code, so this approach seemed a little more concise. If you can think of a more elegant approach, though, I'm open to suggestions!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's ok. I would have happily duplicated the lines, but I understand the desire to avoid that.

@@ -345,8 +346,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$this->harvestSingleRepository($input, $output, $target, $settings);
} catch (\Exception $e) {
$this->writeLine($e->getMessage());
return 1;
if ($e instanceof OaiException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's ok. I would have happily duplicated the lines, but I understand the desire to avoid that.

@demiankatz demiankatz merged commit b0b5573 into dev Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants