exceptions

package
v0.42.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package exceptions holds the errors an assertion returns when it was called wrongly.

InvalidArgumentException is the whole of it: an argument of the wrong type handed to an assertion, naming the position, the type it had to be, and the assertion that was misused. Create builds one and reads that last part off the call stack.

It is about the test being wrong, not the code under test. An assertion that fails reports through testing.T; an assertion that could not run at all returns one of these.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(argument int, typ string) error

Create returns an InvalidArgumentException for the argument at the given one-based position, which had to be of the given type.

The function it names is the caller of Create, which is the assertion that was misused -- naming Create itself would point at this file instead of at the mistake.

Types

type InvalidArgumentException

type InvalidArgumentException struct {
	// Argument is the one-based position of the argument that was wrong.
	Argument int

	// Type is what the argument had to be, written the way the message reads
	// it: "an array", "a string".
	Type string

	// Function is the function that was called with it.
	Function string
}

InvalidArgumentException is an argument of the wrong type handed to an assertion.

It is returned, not panicked: an assertion that could not run at all is a bug in the test, and the caller decides how to report it. Create is the only producer.

func (*InvalidArgumentException) Error

func (e *InvalidArgumentException) Error() string

Error implements error.

Jump to

Keyboard shortcuts

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