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

Create try-catch block for index method #2724

Open
wants to merge 1 commit into
base: feature/TAO-10203-advanced-search
Choose a base branch
from

Conversation

bartlomiejmarszal
Copy link
Contributor

Cause we are now throwing an error on indexing (refer to this PR)

I included try-catch when calling index method

https://oat-sa.atlassian.net/browse/CON-23

Copy link
Contributor

@shpran shpran left a comment

Choose a reason for hiding this comment

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

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • New code is not subject to concurrency issues (if applicable)
  • Feature is working correctly on my local machine (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful

try {
$numberOfIndexed = $searchService->index([$indexDocument]);
} catch (Exception $exception) {
return new Report(Report::TYPE_ERROR, $exception->getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use static method:

Suggested change
return new Report(Report::TYPE_ERROR, $exception->getMessage());
return Report::createFailure($exception->getMessage());

Copy link
Contributor

@boajer boajer left a comment

Choose a reason for hiding this comment

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

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • New code is not subject to concurrency issues (if applicable)
  • Feature is working correctly on my local machine (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful

$numberOfIndexed = $searchService->index([$indexDocument]);
try {
$numberOfIndexed = $searchService->index([$indexDocument]);
} catch (Exception $exception) {
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT?

Suggested change
} catch (Exception $exception) {
} catch (Throwable $exception) {

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.

3 participants