bug

package
v0.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package bug provides utilities for reporting internal bugs, and being notified when they occur.

Philosophically, because gopls runs as a sidecar process that the user does not directly control, sometimes it keeps going on broken invariants rather than panicking. In those cases, bug reports provide a mechanism to alert developers and capture relevant metadata.

Index

Constants

This section is empty.

Variables

View Source
var PanicOnBugs = false

PanicOnBugs controls whether to panic when bugs are reported.

It may be set to true during testing.

Functions

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf calls fmt.Errorf for the given arguments, and reports the resulting error message as a bug.

func Notify

func Notify() <-chan Bug

Notify returns a channel that will be sent the next bug to occur on the server. This channel only ever receives one bug.

func Report

func Report(description string, data Data)

Report records a new bug encountered on the server. It uses reflection to report the position of the immediate caller.

func Reportf

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

Reportf reports a formatted bug message.

Types

type Bug

type Bug struct {
	File        string // file containing the call to bug.Report
	Line        int    // line containing the call to bug.Report
	Description string // description of the bug
	Data        Data   // additional metadata
	Key         string // key identifying the bug (file:line if available)
	Stack       string // call stack
}

A Bug represents an unexpected event or broken invariant. They are used for capturing metadata that helps us understand the event.

func List

func List() []Bug

List returns a slice of bug exemplars -- the first bugs to occur at each callsite.

type Data

type Data map[string]interface{}

Data is additional metadata to record for a bug.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL