better control over diagnostics in language error messages

This commit is contained in:
Grahame Grieve 2025-01-30 18:27:12 +11:00
parent 7aae2cb525
commit bb3a33d9e4
3 changed files with 13 additions and 1 deletions

View File

@ -1469,6 +1469,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
} catch (TerminologyServiceProtectionException e) {
OperationOutcomeIssueComponent iss = new OperationOutcomeIssueComponent(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR, e.getType());
iss.getDetails().setText(e.getMessage());
iss.setDiagnostics(e.getDiagnostics());
issues.add(iss);
return new ValidationResult(IssueSeverity.FATAL, e.getMessage(), e.getError(), issues);
} catch (Exception e) {
@ -1752,6 +1753,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
} catch (TerminologyServiceProtectionException e) {
OperationOutcomeIssueComponent iss = new OperationOutcomeIssueComponent(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR, e.getType());
iss.getDetails().setText(e.getMessage());
iss.setDiagnostics(e.getDiagnostics());
issues.add(iss);
return new ValidationResult(IssueSeverity.FATAL, e.getMessage(), e.getError(), issues);
} catch (Exception e) {

View File

@ -19,12 +19,19 @@ public class TerminologyOperationContext {
private TerminologyServiceErrorClass error;
private IssueType type;
private String diagnostics;
public TerminologyServiceProtectionException(String message, TerminologyServiceErrorClass error, IssueType type) {
super(message);
this.error = error;
this.type = type;
}
public TerminologyServiceProtectionException(String message, TerminologyServiceErrorClass error, IssueType type, String diagnostics) {
super(message);
this.error = error;
this.type = type;
this.diagnostics = diagnostics;
}
public TerminologyServiceErrorClass getError() {
return error;
@ -33,6 +40,9 @@ public class TerminologyOperationContext {
public IssueType getType() {
return type;
}
public String getDiagnostics() {
return diagnostics;
}
}

View File

@ -816,7 +816,7 @@ public class ValueSetValidator extends ValueSetProcessBase {
try {
LanguageTag tag = new LanguageTag(registry, t.getLang());
} catch (Exception e) {
throw new TerminologyServiceProtectionException("Invalid displayLanguage: '"+options.getLanguages().getSource()+"'", TerminologyServiceErrorClass.PROCESSING, IssueType.PROCESSING);
throw new TerminologyServiceProtectionException(context.formatMessage(I18nConstants.INVALID_DISPLAY_NAME, options.getLanguages().getSource()), TerminologyServiceErrorClass.PROCESSING, IssueType.PROCESSING, e.getMessage());
}
}
}