refactor: improve FASTQ error messages with explicit filenames

The options system now tracks explicit file paths via a new accessor and functional option. This filename is threaded through the FASTQ parser chain to replace generic source references in fatal error messages, providing clearer, file-specific diagnostics without altering core parsing logic or test suites.
This commit is contained in:
Eric Coissac
2026-08-19 16:47:36 +02:00
parent eae41ac81c
commit 438893d910
3 changed files with 67 additions and 24 deletions
+19
View File
@@ -35,6 +35,7 @@ type __options__ struct {
csv_auto bool
paired_filename string
source string
filename string
with_feature_table bool
with_pattern bool
with_parent bool
@@ -216,6 +217,16 @@ func (opt Options) Source() string {
return opt.pointer.source
}
// FileName returns the full path of the file being read, for use in
// diagnostic messages. It falls back to Source() when no explicit
// file name has been set (e.g. reading from stdin or a raw reader).
func (opt Options) FileName() string {
if opt.pointer.filename == "" {
return opt.pointer.source
}
return opt.pointer.filename
}
func (opt Options) WithFeatureTable() bool {
return opt.pointer.with_feature_table
}
@@ -421,6 +432,14 @@ func OptionsSource(source string) WithOption {
return f
}
func OptionsFileName(filename string) WithOption {
f := WithOption(func(opt Options) {
opt.pointer.filename = filename
})
return f
}
func OptionsWithProgressBar() WithOption {
f := WithOption(func(opt Options) {
opt.pointer.with_progress_bar = true