elvish: github.com/elves/elvish/pkg/diag Index | Files

package diag

import "github.com/elves/elvish/pkg/diag"

Package diag contains building blocks for formatting and processing diagnostic information.

Index

Package Files

context.go doc.go error.go pprint_error.go range.go

func Complain Uses

func Complain(msg string)

Complain prints a message to stderr in bold and red, adding a trailing newline.

func Complainf Uses

func Complainf(format string, args ...interface{})

Complainf is like Complain, but accepts a format string and arguments.

func PPrintError Uses

func PPrintError(err error)

PPrintError pretty-prints an error. It uses the PPrint method if the error implements PPrinter, and uses Complain to print the error message otherwise.

type Context Uses

type Context struct {
    Name   string
    Source string
    Ranging
    // contains filtered or unexported fields
}

Context is a range of text in a source code. It is typically used for errors that can be associated with a part of the source code, like parse errors and a traceback entry.

func NewContext Uses

func NewContext(name, source string, from, to int) *Context

NewContext creates a new Context.

func (*Context) PPrint Uses

func (c *Context) PPrint(sourceIndent string) string

PPrint pretty-prints a SourceContext.

func (*Context) PPrintCompact Uses

func (c *Context) PPrintCompact(sourceIndent string) string

PPrintCompact pretty-prints a SourceContext, with no line break between the source position range description and relevant source excerpt.

type Error Uses

type Error struct {
    Type    string
    Message string
    Context Context
}

Error represents an error with context that can be pretty-printed.

func (*Error) Error Uses

func (e *Error) Error() string

Error returns a plain text representation of the error.

func (*Error) PPrint Uses

func (e *Error) PPrint(indent string) string

PPrint pretty-prints the error.

func (*Error) Range Uses

func (e *Error) Range() Ranging

Range returns the range of the error.

type Ranger Uses

type Ranger interface {
    // Range returns the range associated with the value.
    Range() Ranging
}

Ranger wraps the Range method.

type Ranging Uses

type Ranging struct {
    From int
    To   int
}

Ranging represents a range [From, To) within an indexable sequence. Structs can embed Ranging to satisfy the Ranger interface.

func (Ranging) Range Uses

func (r Ranging) Range() Ranging

Range returns the Ranging itself.

Package diag imports 6 packages (graph) and is imported by 7 packages. Updated 2019-12-23. Refresh now. Tools for package owners.