lib/manifest.rb in machinery-tool-1.4.0 vs lib/manifest.rb in machinery-tool-1.5.0
- old
+ new
@@ -53,11 +53,11 @@
def validate!
return if !compatible_json?
errors = JsonValidator.new(@hash).validate
if !errors.empty?
- raise Machinery::Errors::SystemDescriptionError.new(errors.join("\n"))
+ raise Machinery::Errors::SystemDescriptionValidationFailed.new(errors)
end
end
def to_hash
@hash
@@ -72,18 +72,19 @@
error_pos = json.split("\n").length - lines.length + 2
block_end = lines.index { |l| l =~ / [\}\]],?$/ }
# remove needless json error information
lines[0].gsub!(/^\d+: (.*)$/, "\\1")
- json_error = lines[0..block_end].join("\n")
if error_pos == 1
json_error = "An opening bracket, a comma or quotation is missing " \
"in one of the global scope definitions or in the meta section. " \
"Unlike issues with the elements of the scopes, our JSON parser " \
"isn't able to locate issues like these."
error_pos = nil
end
+
+ json_error ||= lines[0..block_end].join("\n")
error = "The JSON data of the system description '#{name}' " \
"couldn't be parsed. The following error occured"
error += " around line #{error_pos}" if error_pos
error += " in file '#{path}'" if path