surface more diagnostics
All checks were successful
Generic zig build / build (push) Successful in 32s

This commit is contained in:
Emil Lerch 2026-09-01 14:27:12 -07:00
parent 7692d85745
commit 08f06df810
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -859,7 +859,10 @@ pub const RecordIterator = struct {
} }
} else { } else {
// We should be on a delimiter, otherwise, we should be at the end // We should be on a delimiter, otherwise, we should be at the end
if (state.current_line == null) return error.ParseFailed; if (state.current_line == null) {
try parseError("current line is null", state);
return error.ParseFailed; // fatal
}
state.current_line = state.current_line.?[state.partial_line_column..]; // can't use l here because line may have been reassigned state.current_line = state.current_line.?[state.partial_line_column..]; // can't use l here because line may have been reassigned
state.partial_line_column = 0; state.partial_line_column = 0;
if (state.current_line.?.len == 0) { if (state.current_line.?.len == 0) {
@ -870,8 +873,15 @@ pub const RecordIterator = struct {
return field; return field;
} else { } else {
if (state.current_line.?[0] != state.field_delimiter) { if (state.current_line.?[0] != state.field_delimiter) {
log.err("reset line for next item, first char not '{c}':{?s}", .{ state.field_delimiter, state.current_line }); var buf: [256]u8 = undefined;
return error.ParseFailed; const msg = std.fmt.bufPrint(
&buf,
"reset line for next item, first char not '{c}'",
.{state.field_delimiter},
) catch @panic("bufPrint has no room but should absolutely have more room");
try parseError(msg, state);
return error.ParseFailed; // this is fatal
} }
state.current_line = state.current_line.?[1..]; state.current_line = state.current_line.?[1..];
} }