Skip to content

Commit

Permalink
chore(pattern): Return an error when plaintext parsing encounters an …
Browse files Browse the repository at this point in the history
…unknown char
  • Loading branch information
gabe565 committed Jul 15, 2024
1 parent e6f5fdb commit 6f0f406
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/pattern/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ func FormatStrings() []string {
}

var (
ErrInvalidHeader = errors.New("invalid header")
ErrUnknownExtension = errors.New("unknown pattern extension")
ErrPatternTooBig = errors.New("pattern too big")
ErrInvalidHeader = errors.New("invalid header")
ErrUnknownExtension = errors.New("unknown pattern extension")
ErrPatternTooBig = errors.New("pattern too big")
ErrUnexpectedCharacter = errors.New("unexpected character")
)

const (
Expand Down
2 changes: 2 additions & 0 deletions internal/pattern/plaintext.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func UnmarshalPlaintext(r io.Reader) (Pattern, error) {
case 'O', '*':
tileLine[x] = 1
x++
default:
return pattern, fmt.Errorf("plaintext: %w: %q in line %q", ErrUnexpectedCharacter, string(b), line)
}
}
if len(tileLine) > largest {
Expand Down

0 comments on commit 6f0f406

Please sign in to comment.