diff --git a/internal/pattern/pattern.go b/internal/pattern/pattern.go index 68cfb81..405f57b 100644 --- a/internal/pattern/pattern.go +++ b/internal/pattern/pattern.go @@ -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 ( diff --git a/internal/pattern/plaintext.go b/internal/pattern/plaintext.go index 9766649..b639a40 100644 --- a/internal/pattern/plaintext.go +++ b/internal/pattern/plaintext.go @@ -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 {