Skip to content

Commit

Permalink
Improve error context during validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Apr 16, 2021
1 parent ff38b21 commit ac9adc6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/api/validate.go
Expand Up @@ -17,6 +17,7 @@
package api

import (
"fmt"
"io"
"os"
"time"
Expand Down Expand Up @@ -52,7 +53,7 @@ func Validate(rs io.ReadSeeker, conf *pdfcpu.Configuration) error {
if conf.ValidationMode == pdfcpu.ValidationStrict {
s = " (try -mode=relaxed)"
}
err = errors.Wrap(err, "validation error"+s)
err = errors.Wrap(err, fmt.Sprintf("validation error (obj#:%d)%s", ctx.CurObj, s))
}

dur2 := time.Since(from2).Seconds()
Expand Down
2 changes: 1 addition & 1 deletion pkg/pdfcpu/string.go
Expand Up @@ -170,7 +170,7 @@ func Unescape(s string) ([]byte, error) {

// Relax for issue 305 and also accept "\ ".
if !strings.ContainsRune(" nrtbf()01234567", rune(c)) {
return nil, errors.Errorf("Unescape: illegal escape sequence \\%c detected", c)
return nil, errors.Errorf("Unescape: illegal escape sequence \\%c detected: <%s>", c, s)
}

var octal bool
Expand Down

0 comments on commit ac9adc6

Please sign in to comment.