Switch back to --diagnostic-format human

This commit is contained in:
David Vogel 2024-12-19 16:14:11 +01:00
parent 916336f361
commit 0a600dd2a1
2 changed files with 3 additions and 7 deletions

2
cli.go
View File

@ -55,7 +55,7 @@ func (c CLI) Render(input io.Reader, output io.Writer, options *CLIOptions) erro
if options != nil {
args = append(args, options.Args()...)
}
args = append(args, "--diagnostic-format", "short", "-", "-")
args = append(args, "--diagnostic-format", "human", "-", "-")
// Get path of executable.
execPath := ExecutablePath

View File

@ -19,10 +19,6 @@ type Error struct {
}
func (e *Error) Error() string {
if e.Message != "" {
return e.Message
}
return e.Raw
}
@ -50,8 +46,8 @@ func (e *ErrorWithPath) Unwrap() error {
return e.Inner
}
var stderrRegex = regexp.MustCompile(`^error: (?<error>.+)\n`)
var stderrWithPathRegex = regexp.MustCompile(`^(?<path>.+):(?<line>\d+):(?<column>\d+): error: (?<error>.+)\n$`)
var stderrRegex = regexp.MustCompile(`(?s)^error: (?<error>.+?)\n`)
var stderrWithPathRegex = regexp.MustCompile(`(?s)^error: (?<error>.+?)\n\s+┌─ (?<path>.+?):(?<line>\d+):(?<column>\d+)\n`)
// ParseStderr will parse the given stderr output and return a suitable error object.
// Depending on the stderr message, this will return either a typst.Error or a typst.ErrorWithPath error.