Skip to content

🕯️Fancy diagnostic reporting for text-based programming languages.

Notifications You must be signed in to change notification settings

vyacheslavhere/candle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕯️ Candle

Candle is simple and fancy diagnostic reporting framework.

Features

  • Easy creation of errors with zero, one or multiple diagnostics.
  • Customizable error display styles.
  • Supports specifying file, line, column, and span locations for errors.

Installation

go get github.com/vyacheslavhere/candle

Usage

Simple 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()))
}
image

Customizing style

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
}

About

🕯️Fancy diagnostic reporting for text-based programming languages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages