diff --git a/qlib/FixedLengthUtil.qm b/qlib/FixedLengthUtil.qm index 48688be62d..71380f8edf 100644 --- a/qlib/FixedLengthUtil.qm +++ b/qlib/FixedLengthUtil.qm @@ -237,6 +237,8 @@ public class FixedLengthUtil::FixedLengthAbstractIterator { /** @param spec Fixed-length line specification; see @ref fixedlengthspec for more information @param opts Global options; see @ref fixedlengthglobals for more information + + @throw FIXED-LENGTH-UTIL-INVALID-SPEC invalid record specification; invalid type or missing field length */ constructor(hash spec, *hash opts) { m_specs = spec; @@ -245,6 +247,8 @@ public class FixedLengthUtil::FixedLengthAbstractIterator { # Determine line lengths of each spec, for use by the default identifyType() method. We do this by building a reverse length -> type table. m_line_lengths = hash(); foreach string k in (m_specs.keyIterator()) { + if (m_specs{k}.typeCode() != NT_HASH) + throw "FIXED-LENGTH-UTIL-INVALID-SPEC", sprintf("expecting a record description hash assigned to record key %y; got type %y instead (value: %y)", k, m_specs{k}.type(), m_specs{k}); int len = 0; foreach string c in (m_specs{k}.keyIterator()) { if (!m_specs{k}{c}.length)