File: error.go

package info (click to toggle)
golang-github-go-quicktest-qt 1.101.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 236 kB
  • sloc: makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Licensed under the MIT license, see LICENCE file for details.

package qt

import (
	"fmt"
)

// BadCheckf returns an error used to report a problem with the checker
// invocation or testing execution itself (like wrong number or type of
// arguments) rather than a real Check or Assert failure.
// This helper can be used when implementing checkers.
func BadCheckf(format string, a ...any) error {
	e := badCheck(fmt.Sprintf(format, a...))
	return &e
}

// IsBadCheck reports whether the given error has been created by BadCheckf.
// This helper can be used when implementing checkers.
func IsBadCheck(err error) bool {
	_, ok := err.(*badCheck)
	return ok
}

type badCheck string

// Error implements the error interface.
func (e *badCheck) Error() string {
	return "bad check: " + string(*e)
}

// ErrSilent is the error used when there is no need to include in the failure
// output the "error" and "check" keys and all the keys automatically
// added for args. This helper can be used when implementing checkers.
var ErrSilent = fmt.Errorf("silent failure")