File: errors.go

package info (click to toggle)
golang-github-sebdah-goldie 2.5.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 200 kB
  • sloc: makefile: 2
file content (74 lines) | stat: -rw-r--r-- 1,777 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package goldie

import "fmt"

// errFixtureNotFound is thrown when the fixture file could not be found.
type errFixtureNotFound struct {
	message string
}

// newErrFixtureNotFound returns a new instance of the error.
func newErrFixtureNotFound() *errFixtureNotFound {
	return &errFixtureNotFound{
		// TODO: flag name should be based on the variable value
		message: "Golden fixture not found. Try running with -update flag.",
	}
}

// Error returns the error message.
func (e *errFixtureNotFound) Error() string {
	return e.message
}

// errFixtureMismatch is thrown when the actual and expected data is not
// matching.
type errFixtureMismatch struct {
	message string
}

// newErrFixtureMismatch returns a new instance of the error.
func newErrFixtureMismatch(message string) *errFixtureMismatch {
	return &errFixtureMismatch{
		message: message,
	}
}

func (e *errFixtureMismatch) Error() string {
	return e.message
}

// errFixtureDirecetoryIsFile is thrown when the fixture directory is a file
type errFixtureDirectoryIsFile struct {
	file string
}

// newFixtureDirectoryIsFile returns a new instance of the error.
func newErrFixtureDirectoryIsFile(file string) *errFixtureDirectoryIsFile {
	return &errFixtureDirectoryIsFile{
		file: file,
	}
}

func (e *errFixtureDirectoryIsFile) Error() string {
	return fmt.Sprintf("fixture folder is a file: %s", e.file)
}

func (e *errFixtureDirectoryIsFile) File() string {
	return e.file
}

// errMissingKey is thrown when a value for a template is missing
type errMissingKey struct {
	message string
}

// newErrMissingKey returns a new instance of the error.
func newErrMissingKey(message string) *errMissingKey {
	return &errMissingKey{
		message: message,
	}
}

func (e *errMissingKey) Error() string {
	return e.message
}