Skip to content

Commit cd56b1a

Browse files
committed
Throw error instead of warning when an element from the wrong type is read
1 parent 360f9ad commit cd56b1a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/pwf2dict.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,9 @@ function _parse_line_element!(data::Dict{String, Any}, line::String, section::Ab
496496
else
497497
data[field] = element
498498
end
499-
catch
499+
catch message
500500
if !_needs_default(element)
501-
Memento.warn(_LOGGER, "Could not parse $element to $dtype inside $section section, setting it as a String")
501+
throw(Memento.error(_LOGGER, "Parsing error at section $section: $field should be of type $dtype, received $element"))
502502
end
503503
data[field] = element
504504
end
@@ -519,9 +519,9 @@ function _parse_line_element!(data::Dict{String, Any}, lines::Vector{String}, se
519519
if mn_type != String && mn_type != Char
520520
try
521521
data[line[k]] = parse(mn_type, line[v])
522-
catch
522+
catch message
523523
if !_needs_default(line[v])
524-
Memento.warn(_LOGGER, "Could not parse $(line[v]) to $mn_type, setting it as a String")
524+
throw(Memento.error(_LOGGER, "Parsing error at section $section: $field should be of type $dtype, received $element"))
525525
end
526526
!_needs_default(line[k]) ? data[line[k]] = line[v] : nothing
527527
end

0 commit comments

Comments
 (0)