-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
55 lines (44 loc) · 1.22 KB
/
error.go
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
package domain
import (
"github.com/pkg/errors"
)
// ErrGameOver indicates that the game has finished and no more play can take place.
type ErrGameOver struct {
error
}
func errGameOver() error {
return ErrGameOver{
errors.Errorf(`The game is over.`)}
}
// ErrInvalidTurns indicates that the specified number of turns is not acceptable.
type ErrInvalidTurns struct {
error
}
func errInvalidTurns(turns int) error {
return ErrInvalidTurns{
errors.Errorf(`The number of turns '%v' is not valid.`, turns)}
}
// ErrInvalidWord indicates that a word is not valid choice for the game
type ErrInvalidWord struct {
error
}
func errInvalidWord(word string) error {
return ErrInvalidWord{
errors.Errorf(`The word '%v' is not valid.`, word)}
}
// ErrInvalidLetter indicates that a letter is not valid choice for the game
type ErrInvalidLetter struct {
error
}
func errInvalidLetter(letter rune) error {
return ErrInvalidLetter{
errors.Errorf(`The letter '%v' is not valid.`, letter)}
}
// ErrAlreadyUsed indicates that the letter choice has previously been used.
type ErrAlreadyUsed struct {
error
}
func errAlreadyUsed(r rune) error {
return ErrAlreadyUsed{
errors.Errorf(`You have previously used the letter '%c'.`, r)}
}