Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Analyzer = &analysis.Analyzer{ Name: "serum", Doc: "Checks that any function that has a structured docstring enumerating Serum-style error codes is telling the truth.", Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: runVerify, FactTypes: []analysis.Fact{ new(ErrorCodes), new(ErrorConstructor), new(ErrorType), new(ErrorInterface), }, }
Functions ¶
This section is empty.
Types ¶
type CodeSet ¶
type CodeSet map[string]struct{}
func Difference ¶
Difference creates a new set containing the elements of the given set (lhs), minus the elements in the given subtrahend (rhs). The input sets are not modified.
func SliceToSet ¶
SliceToSet creates a set containing all values of the given slice, removing duplicates. The slice is not modified.
func Union ¶
Union returns a set containing all values that appear in either input set. The input sets are not modified.
type ErrorCodeField ¶
ErrorCodeField is part of ErrorType, and declares the field that might be returned by the Code() method of the ree.Error.
func (*ErrorCodeField) String ¶
func (f *ErrorCodeField) String() string
type ErrorCodes ¶
type ErrorCodes struct {
Codes CodeSet
}
func (*ErrorCodes) AFact ¶
func (*ErrorCodes) AFact()
func (*ErrorCodes) String ¶
func (e *ErrorCodes) String() string
type ErrorConstructor ¶
type ErrorConstructor struct {
CodeParamPosition int
}
ErrorConstructor is a fact that is used to tag functions that are error constructors, meaning they take an error code parameter (string) and return an error.
For example a constructor function "NewError(code, message string) error { return &Error{code, message} }" gets an ErrorConstructor{CodeParamPosition: 0} fact.
func (*ErrorConstructor) AFact ¶
func (*ErrorConstructor) AFact()
func (*ErrorConstructor) String ¶
func (e *ErrorConstructor) String() string
type ErrorInterface ¶
type ErrorInterface struct { // ErrorMethods contains the names of all methods in the interface, // that have error codes declared along with their declared error codes. // // For all types implementing this interface, these methods must be checked to // make sure they only contain a subset of the error codes declared in the interface. ErrorMethods map[string]CodeSet }
ErrorInterface is a fact emitted by the analyser, marking an interface as containing methods that declare error codes.
func (*ErrorInterface) AFact ¶
func (*ErrorInterface) AFact()
func (*ErrorInterface) String ¶
func (e *ErrorInterface) String() string
type ErrorType ¶
type ErrorType struct { Codes []string // error codes, or nil Field *ErrorCodeField // field information, or nil }
ErrorType is a fact about a ree.Error type, declaring which error codes Code() might return, and/or what field gets returned by a call to Code().