/
errors.go
24 lines (20 loc) · 1.03 KB
/
errors.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
package main
import "errors"
type ValidationError error
var (
errNoUsername = ValidationError(errors.New("You must supply a username"))
errNoEmail = ValidationError(errors.New("You must supply an email"))
errNoPassword = ValidationError(errors.New("You must supply a password"))
errPasswordTooShort = ValidationError(errors.New("Your password too short"))
errUsernameExists = ValidationError(errors.New("That username is taken"))
errEmailExists = ValidationError(errors.New("That email is taken"))
errInfoIncorect = ValidationError(errors.New("username or password wrong"))
errPasswordMisMatch = ValidationError(errors.New("Password did not match"))
errInvalidImageType = ValidationError(errors.New("Please upload only jpeg gif or png images"))
errNoImage = ValidationError(errors.New("Please select an image to upload"))
errInvalidImageURL = ValidationError(errors.New("Could not download image from url"))
)
func IsValidationError(err error) bool {
_, ok := err.(ValidationError)
return ok
}