-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use error structs instead of fmt.Errorf (#55)
* Refactor errors * Fix go vet
- Loading branch information
1 parent
4ebc4e8
commit 2f27407
Showing
4 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package internal | ||
|
||
import "fmt" | ||
|
||
type ErrSnapshotCreated struct { | ||
Name string | ||
Contents string | ||
} | ||
|
||
func (e ErrSnapshotCreated) Error() string { | ||
return fmt.Sprintf("snapshot created for test %s, with contents:\n%s", e.Name, e.Contents) | ||
} | ||
|
||
type ErrSnapshotUpdated struct { | ||
Name string | ||
Diff string | ||
} | ||
|
||
func (e ErrSnapshotUpdated) Error() string { | ||
return fmt.Sprintf("snapshot %s updated:\n%s", e.Name, e.Diff) | ||
} | ||
|
||
type ErrSnapshotMismatch struct { | ||
Diff string | ||
} | ||
|
||
func (e ErrSnapshotMismatch) Error() string { | ||
return fmt.Sprintf("snapshot not equal:\n%s", e.Diff) | ||
} | ||
|
||
type ErrNoSnapshot struct { | ||
Name string | ||
} | ||
|
||
func (e ErrNoSnapshot) Error() string { | ||
return fmt.Sprintf("snapshot %s does not exist", e.Name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters