Candle is simple and fancy diagnostic reporting framework.
- Easy creation of errors with zero, one or multiple diagnostics.
- Customizable error display styles.
- Supports specifying file, line, column, and span locations for errors.
go get github.com/vyacheslavhere/candleSimple error with two diagnostics:
package main
import (
c "candle/core"
"fmt"
)
func main() {
error := c.NewError("Error occurred").
WithDiagnostic(c.NewDiagnostic(
"./test.err",
c.NewLocation(0, 7, 28),
"Сould not concatenate `str` and `int`.",
)).
WithDiagnostic(c.NewDiagnostic(
"./test.err",
c.NewLocation(1, 5, 10),
"Invalid function name.",
))
fmt.Printf("%s", error.ToString(c.DefaultStyle()))
}
You can easily make your own style for errors, using Style struct:
type Style struct {
ErrorPrefix string // Prefix for the error message (e.g. "Error: ")
ErrorPrefixColor string // Color for the error prefix
TitleColor string // Color for the error title
FileNameColor string // Color for the filename
FileNameColon string // Character after the filename (e.g. ":")
FileNameColonColor string // Color for the colon
LineNumberColor string // Color for the line number
LineColor string // Color for the line text
SpaceChar string // Character used for spacing
ArrowChar string // Character used for pointing to the error span (e.g. "^")
ArrowCharColor string // Color for the arrow
CaptionColor string // Color for the diagnostic message
}