Skip to content

Commit

Permalink
chore(pattern): Improve pattern load error text
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Nov 13, 2024
1 parent f3632cd commit 531c3ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/pattern/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Default() *Pattern {
var (
ErrInvalidHeader = errors.New("invalid header")
ErrUnexpectedCharacter = errors.New("unexpected character")
ErrInferFailed = errors.New("unable to infer pattern file type")
ErrDetectFailed = errors.New("unable to detect pattern file format")
)

const (
Expand Down Expand Up @@ -163,7 +163,7 @@ func Unmarshal(r io.Reader) (*Pattern, error) {
case bytes.HasPrefix(firstLine, []byte("!")), bytes.HasPrefix(firstLine, []byte(".")), bytes.HasPrefix(firstLine, []byte("O")):
return UnmarshalPlaintext(bytes.NewReader(buf))
default:
return nil, ErrInferFailed
return nil, ErrDetectFailed
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pattern/plaintext.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func UnmarshalPlaintext(r io.Reader) (*Pattern, error) {
pattern.Tree.Set(p, 1)
p.X++
default:
return nil, fmt.Errorf("plaintext: %w: %q in line %q", ErrUnexpectedCharacter, string(b), line)
return nil, fmt.Errorf("plaintext: %w: %q in line: %q", ErrUnexpectedCharacter, string(b), line)
}
}
p.X = 0
Expand Down
2 changes: 1 addition & 1 deletion internal/pattern/rle.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ scan:
matches := headerRe.FindStringSubmatch(scanner.Text())

if len(matches) == 0 {
return nil, fmt.Errorf("rle: %w: %s", ErrInvalidHeader, line)
return nil, fmt.Errorf("rle: %w: %q", ErrInvalidHeader, line)
}

var w, h int
Expand Down

0 comments on commit 531c3ec

Please sign in to comment.