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

Search Parameter validation failure issues logged #3341

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Threading.Tasks;
using EnsureThat;
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Support;
using MediatR;
using Microsoft.Extensions.Logging;
using Microsoft.Health.Extensions.DependencyInjection;
Expand Down Expand Up @@ -261,10 +262,18 @@ private async Task LoadSearchParamsFromDataStore(CancellationToken cancellationT
catch (SearchParameterNotSupportedException ex)
{
_logger.LogWarning(ex, "Error loading search parameter {Url} from data store.", searchParam.GetStringScalar("url"));
foreach (OperationOutcomeIssue issue in ex.Issues)
fhibf marked this conversation as resolved.
Show resolved Hide resolved
{
_logger.LogWarning(issue.Diagnostics);
}
}
catch (InvalidDefinitionException ex)
Copy link
Contributor

@fhibf fhibf Jun 8, 2023

Choose a reason for hiding this comment

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

Maybe we can simplify this part of the code with:

catch (FhirException ex)
{
    StringBuilder issueDetails = new StringBuilder();
    foreach (OperationOutcomeIssue issue in ex.Issues)
    {
        issueDetails.Append(issue.Diagnostics).Append("; ");
    }
    
    _logger.LogWarning(ex, "Error loading search parameter {Url} from data store. Issues: {Issues}", searchParam.GetStringScalar("url"), issueDetails.ToString());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

As InvalidDefinitionException and SearchParameterNotSupportedException inherit from FhirException, a single catch block can simplify the code.

{
_logger.LogWarning(ex, "Error loading search parameter {Url} from data store.", searchParam.GetStringScalar("url"));
foreach (OperationOutcomeIssue issue in ex.Issues)
fhibf marked this conversation as resolved.
Show resolved Hide resolved
{
_logger.LogWarning(issue.Diagnostics);
}
}
catch (Exception ex)
{
Expand Down