eliminate platform dependency in error message

This commit is contained in:
Grahame Grieve 2022-10-20 10:59:17 +11:00
parent 648883c87b
commit 4850a4c740
3 changed files with 13 additions and 1 deletions

View File

@ -623,6 +623,7 @@ public class I18nConstants {
public static final String VALIDATION_VAL_PROFILE_UNKNOWN = "Validation_VAL_Profile_Unknown";
public static final String VALIDATION_VAL_PROFILE_UNKNOWN_NOT_POLICY = "VALIDATION_VAL_PROFILE_UNKNOWN_NOT_POLICY";
public static final String VALIDATION_VAL_PROFILE_UNKNOWN_ERROR = "VALIDATION_VAL_PROFILE_UNKNOWN_ERROR";
public static final String VALIDATION_VAL_PROFILE_UNKNOWN_ERROR_NETWORK = "VALIDATION_VAL_PROFILE_UNKNOWN_ERROR_NETWORK";
public static final String VALIDATION_VAL_PROFILE_WRONGTYPE = "Validation_VAL_Profile_WrongType";
public static final String VALIDATION_VAL_PROFILE_WRONGTYPE2 = "Validation_VAL_Profile_WrongType2";
public static final String VALIDATION_VAL_UNKNOWN_PROFILE = "Validation_VAL_Unknown_Profile";

View File

@ -237,6 +237,7 @@ Validation_VAL_Profile_SliceOrder = As specified by profile {0}, Element ''{1}''
Validation_VAL_Profile_Unknown = Profile reference ''{0}'' has not been checked because it is unknown
VALIDATION_VAL_PROFILE_UNKNOWN_NOT_POLICY = Profile reference ''{0}'' has not been checked because it is unknown, and the validator is set to not fetch unknown profiles
VALIDATION_VAL_PROFILE_UNKNOWN_ERROR = Profile reference ''{0}'' has not been checked because it is unknown, and fetching it resulted in the error {1}
VALIDATION_VAL_PROFILE_UNKNOWN_ERROR_NETWORK = Profile reference ''{0}'' has not been checked because it is unknown, and the host {1} cannot be found
Validation_VAL_Unknown_Profile = Unknown profile {0}
VALIDATION_VAL_PROFILE_DEPENDS_NOT_RESOLVED = Profile {1} identifies {2} as a dependency (using the extension http://hl7.org/fhir/StructureDefinition/structuredefinition-dependencies), but this profile could not be found
XHTML_XHTML_Attribute_Illegal = Illegal attribute name in the XHTML (''{0}'' on ''{1}'')

View File

@ -38,6 +38,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Calendar;
@ -4637,8 +4639,16 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} catch (Exception e) {
if (STACK_TRACE) { e.printStackTrace(); }
crLookups.put(url, new CanonicalResourceLookupResult(e.getMessage()));
if (e.getMessage().startsWith("java.net.UnknownHostException:")) {
try {
warning(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath() + ".meta.profile[" + i + "]", false, I18nConstants.VALIDATION_VAL_PROFILE_UNKNOWN_ERROR_NETWORK, profile.primitiveValue(), new URI(url).getHost());
} catch (URISyntaxException e1) {
warning(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath() + ".meta.profile[" + i + "]", false, I18nConstants.VALIDATION_VAL_PROFILE_UNKNOWN_ERROR_NETWORK, profile.primitiveValue(), "??");
}
} else {
warning(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath() + ".meta.profile[" + i + "]", false, I18nConstants.VALIDATION_VAL_PROFILE_UNKNOWN_ERROR, profile.primitiveValue(), e.getMessage());
}
}
if (sd != null) {
context.cacheResource(sd);
}