r.go | 11 ++++++++--- diff --git a/r.go b/r.go index 7400e07f03e1724923a30c38ccfbe995e477afb11700dd922a89c0222442764e..a100f0996112eb7f858e8a16242b24158be8e152967f8ba38f5a3368c87e451e 100644 --- a/r.go +++ b/r.go @@ -17,13 +17,18 @@ package recfile import ( "bufio" - "errors" "io" "strings" ) type Reader struct { scanner *bufio.Scanner +} + +type FormatErr string + +func (err FormatErr) Error() string { + return string(err) } // Create Reader for iterating through the records. It uses @@ -118,7 +123,7 @@ } name, line = getKeyValue(text) if name == "" { - return fields, errors.New("invalid field format") + return fields, FormatErr("invalid field format") } if len(line) > 0 && line[len(line)-1] == '\\' { @@ -129,7 +134,7 @@ lines = append(lines, line) } } if continuation { - return fields, errors.New("left continuation") + return fields, FormatErr("left continuation") } if len(lines) > 0 { fields = append(fields, Field{name, strings.Join(lines, "")})