Add ErrNotFound, return it from WriteAudio/Image.
Dmitry Chestnykh dmitry@codingrobots.com
Sun, 24 Apr 2011 14:34:11 +0200
1 files changed,
4 insertions(+),
2 deletions(-)
jump to
M
captcha.go
→
captcha.go
@@ -11,6 +11,8 @@
// Standard number of digits in captcha. const StdLength = 6 +var ErrNotFound = os.NewError("captcha with the given id not found") + var globalStore = newStore() // RandomDigits returns a byte slice of the given length containing random@@ -54,7 +56,7 @@ // given id. The image will have the given width and height.
func WriteImage(w io.Writer, id string, width, height int) os.Error { d := globalStore.getDigits(id) if d == nil { - return os.NewError("captcha id not found") + return ErrNotFound } _, err := NewImage(d, width, height).WriteTo(w) return err@@ -65,7 +67,7 @@ // given id.
func WriteAudio(w io.Writer, id string) os.Error { d := globalStore.getDigits(id) if d == nil { - return os.NewError("captcha id not found") + return ErrNotFound } _, err := NewAudio(d).WriteTo(w) return err