mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudformation): return ValidationError when JSON parse error has no location (#9213)
This commit is contained in:
1 parent
78ea3c90d9
commit
188371eabc
3 files changed
+38
-3
No files matched your search
+6
-3
@@ -48,14 +48,17 @@ final class CloudFormationTemplateParser {
|
||||
return new CloudFormationYamlParser(objectMapper).parse(body);
|
||||
} catch (YAMLException yamlError) {
|
||||
if (jsonError != null && trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
||||
JsonLocation at = jsonError.getLocation();
|
||||
throw new TemplateFormatException("JSON not well-formed. (line " + at.getLineNr()
|
||||
+ ", column " + at.getColumnNr() + ")", jsonError);
|
||||
throw new TemplateFormatException("JSON not well-formed." + position(jsonError), jsonError);
|
||||
}
|
||||
throw new TemplateFormatException("YAML not well-formed." + position(yamlError), yamlError);
|
||||
}
|
||||
}
|
||||
|
||||
private static String position(JsonProcessingException error) {
|
||||
JsonLocation at = error.getLocation();
|
||||
return at == null ? "" : " (line " + at.getLineNr() + ", column " + at.getColumnNr() + ")";
|
||||
}
|
||||
|
||||
/** Where the YAML parser stopped, 1-based as CloudFormation counts; nothing for an error with no mark. */
|
||||
private static String position(YAMLException error) {
|
||||
if (!(error instanceof MarkedYAMLException marked)) {
|
||||
|
||||
Reference in new issue
Block a user