Debian Codegraph @

errors.go

raw symbols SCIP
1 package goldie
2
3 import "fmt"
4
5 // errFixtureNotFound is thrown when the fixture file could not be found.
6 type errFixtureNotFound struct {
7 message string
8 }
9
10 // newErrFixtureNotFound returns a new instance of the error.
11 func newErrFixtureNotFound() *errFixtureNotFound {
12 return &errFixtureNotFound{
13 // TODO: flag name should be based on the variable value
14 message: "Golden fixture not found. Try running with -update flag.",
15 }
16 }
17
18 // Error returns the error message.
19 func (e *errFixtureNotFound) Error() string {
20 return e.message
21 }
22
23 // errFixtureMismatch is thrown when the actual and expected data is not
24 // matching.
25 type errFixtureMismatch struct {
26 message string
27 }
28
29 // newErrFixtureMismatch returns a new instance of the error.
30 func newErrFixtureMismatch(message string) *errFixtureMismatch {
31 return &errFixtureMismatch{
32 message: message,
33 }
34 }
35
36 func (e *errFixtureMismatch) Error() string {
37 return e.message
38 }
39
40 // errFixtureDirecetoryIsFile is thrown when the fixture directory is a file
41 type errFixtureDirectoryIsFile struct {
42 file string
43 }
44
45 // newFixtureDirectoryIsFile returns a new instance of the error.
46 func newErrFixtureDirectoryIsFile(file string) *errFixtureDirectoryIsFile {
47 return &errFixtureDirectoryIsFile{
48 file: file,
49 }
50 }
51
52 func (e *errFixtureDirectoryIsFile) Error() string {
53 return fmt.Sprintf("fixture folder is a file: %s", e.file)
54 }
55
56 func (e *errFixtureDirectoryIsFile) File() string {
57 return e.file
58 }
59
60 // errMissingKey is thrown when a value for a template is missing
61 type errMissingKey struct {
62 message string
63 }
64
65 // newErrMissingKey returns a new instance of the error.
66 func newErrMissingKey(message string) *errMissingKey {
67 return &errMissingKey{
68 message: message,
69 }
70 }
71
72 func (e *errMissingKey) Error() string {
73 return e.message
74 }