// pre-reads beginning delimiter length - 1 bytes from Reader
for i := 0; i < len(left)-1; i++ {
if c, err = r.ReadByte(); err != nil {
- return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s", buf.Len(), err)
+ return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s\n%.100s...", buf.Len(), err, buf.String())
}
if err = buf.WriteByte(c); err != nil {
return nil, err
// is expected that the delimiter only contains one character.
for {
if c, err = r.ReadByte(); err != nil {
- return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s", buf.Len(), err)
+ return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s\n%.100s...", buf.Len(), err, buf.String())
}
if err = buf.WriteByte(c); err != nil {
return nil, err
if err != nil {
// It is ok that the end delimiter ends with EOF
if err != io.EOF || level != 1 {
- return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s", buf.Len(), err)
+ return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s\n%.100s...", buf.Len(), err, buf.String())
}
} else {
switch c {
return nil, err
}
if c, err = r.ReadByte(); err != nil {
- return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s", buf.Len(), err)
+ return nil, fmt.Errorf("unable to read frontmatter at filepos %d: %s\n%.100s...", buf.Len(), err, buf.String())
}
if c != '\n' {
return nil, fmt.Errorf("frontmatter delimiter must be followed by CR+LF or LF but those can't be found at filepos %d", buf.Len())