errs

package
v0.0.0-...-485ca13 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

The errs package contains stuff related with errors.

Index

Constants

View Source
const (
	// statusCodeSuccess indicates a successful execution.
	StatusCodeSuccess = 0

	// statusCodeBadUsage indicates some user error in the usage of the romualdo
	// tool (e.g., passing the wrong number of arguments, or passing a
	// nonexisting command-line flag).
	StatusCodeBadUsage = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BadUsage

type BadUsage struct {
	// Message contains a message explaining what happened.
	Message string
}

BadUsage is an error that happened because the romualdo tool was called in the wrong way (like incorrect command-line arguments).

func NewBadUsage

func NewBadUsage(format string, a ...any) *BadUsage

NewBadUsage is a handy way to create a BadUsage error.

func (*BadUsage) Error

func (e *BadUsage) Error() string

Error converts the BadUsage to a string. Fulfills the error interface.

func (*BadUsage) ExitCode

func (e *BadUsage) ExitCode() int

ExitCode fulfills the Error interface.

type CompileTime

type CompileTime struct {
	// Message contains a user-friendly error message.
	Message string

	// FileName is the name of the file where the error was detected.
	FileName string

	// Line contains the line number where the error was detected.
	Line int

	// Lexeme contains the lexeme where the error was detected.
	Lexeme string
}

CompileTime is an error used to represent any compile-time error.

func NewCompileTime

func NewCompileTime(fileName string, line int, format string, a ...any) *CompileTime

NewCompileTime is a handy way to create a CompileTime error at some specific line of code.

func NewCompileTimeWithoutLine

func NewCompileTimeWithoutLine(fileName, format string, a ...any) *CompileTime

NewCompileTimeWithoutLine is a handy way to create a CompileTime error that is not related with a specific line of code.

func (*CompileTime) Error

func (e *CompileTime) Error() string

Error converts the CompileTime to a string. Fulfills the error interface.

func (*CompileTime) ExitCode

func (e *CompileTime) ExitCode() int

ExitCode fulfills the Error interface.

type CompileTimeCollection

type CompileTimeCollection struct {
	// Errors is the collection of CompileTime errors.
	Errors []*CompileTime
}

CompileTimeCollection is a collection of CompileTime errors.

func (*CompileTimeCollection) Add

func (e *CompileTimeCollection) Add(err *CompileTime)

Add adds a new error to the collection of errors. A no-op if err is nil.

func (*CompileTimeCollection) AddMany

func (e *CompileTimeCollection) AddMany(errs *CompileTimeCollection)

AddMany adds all the errors in errs to e.

func (*CompileTimeCollection) Error

func (e *CompileTimeCollection) Error() string

Error converts the CompileTimeCollection to a string -- a multiline string at that, with one error per line. Fulfills the error interface.

func (*CompileTimeCollection) ExitCode

func (e *CompileTimeCollection) ExitCode() int

ExitCode fulfills the Error interface.

func (*CompileTimeCollection) IsEmpty

func (e *CompileTimeCollection) IsEmpty() bool

IsEmpty checks if this CompileTimeCollection is empty (i.e., if it is collection of errors without any errors inside it).

type Error

type Error interface {
	error
	ExitCode() int
}

Error is a Romualdo error.

type ICE

type ICE struct {
	// Message contains some message to contextualize the situation in which the
	// error happened. Hopefully will be good enough to help fixing the bug.
	Message string
}

ICE is an Internal Compiler Error. Used to report some unexpected issue with the compiler -- like when we find it is on a state it wasn't expected to be. It's always a bug.

func NewICE

func NewICE(format string, a ...any) *ICE

NewICE is a handy way to create an ICE.

func (*ICE) Error

func (e *ICE) Error() string

Error converts the ICE to a string. Fulfills the error interface.

func (*ICE) ExitCode

func (e *ICE) ExitCode() int

ExitCode fulfills the Error interface.

type RomualdoTool

type RomualdoTool struct {
	// Message contains a message explaining what went wrong.
	Message string
}

RomualdoTool is an error that happened when running the romualdo tool that doesn't fit any of the other error types. Could be, e.g., an error opening some file.

func NewRomualdoTool

func NewRomualdoTool(format string, a ...any) *RomualdoTool

NewRomualdoTool is a handy way to create a RomualdoTool error.

func (*RomualdoTool) Error

func (e *RomualdoTool) Error() string

Error converts the RomualdoTool to a string. Fulfills the error interface.

func (*RomualdoTool) ExitCode

func (e *RomualdoTool) ExitCode() int

ExitCode fulfills the Error interface.

type Runtime

type Runtime struct {
	// Message contains a message explaining what happened.
	Message string
}

Runtime is an error that happened while running a Storyworld. Not sure I am ready to vouch for this, but I think that this if this ever happens, it means there is a bug in the tooling.

func NewRuntime

func NewRuntime(format string, a ...any) *Runtime

NewRuntime is a handy way to create a Runtime error.

func (*Runtime) Error

func (e *Runtime) Error() string

Error converts the Runtime to a string. Fulfills the error interface.

func (*Runtime) ExitCode

func (e *Runtime) ExitCode() int

ExitCode fulfills the Error interface.

type TestSuite

type TestSuite struct {
	// TestCase contains the path to the test case that failed.
	TestCase string

	// Message contains a message explaining how the test failed.
	Message string
}

TestSuite is an error that happened when running the Romualdo test suite (i.e.¸when testing Romualdo itself).

func NewTestSuite

func NewTestSuite(testCase, format string, a ...any) *TestSuite

NewTestSuite is a handy way to create a TestSuite error.

func (*TestSuite) Error

func (e *TestSuite) Error() string

Error converts the TestSuite to a string. Fulfills the error interface.

func (*TestSuite) ExitCode

func (e *TestSuite) ExitCode() int

ExitCode fulfills the Error interface.

Jump to

Keyboard shortcuts

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