internal/short: include invalid input in error

If the input is invalid, it generally helps to see it (including any
invisible characters as printed by %q) in the error message. Do that.

Change-Id: Ibe179a7c03c29b1caa0532aff08cee1b11fbb051
Reviewed-on: https://go-review.googlesource.com/c/website/+/406354
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
diff --git a/internal/short/short.go b/internal/short/short.go
index 8cbbb59..7c4c798 100644
--- a/internal/short/short.go
+++ b/internal/short/short.go
@@ -192,10 +192,10 @@
 // putLink validates the provided link and puts it into the datastore.
 func (h server) putLink(ctx context.Context, link *Link) error {
 	if !validKey.MatchString(link.Key) {
-		return errors.New("invalid key; must match " + validKey.String())
+		return fmt.Errorf("invalid key %q; must match %s", link.Key, validKey.String())
 	}
 	if _, err := url.Parse(link.Target); err != nil {
-		return fmt.Errorf("bad target: %v", err)
+		return fmt.Errorf("bad target %q: %v", link.Target, err)
 	}
 	k := datastore.NameKey(kind, link.Key, nil)
 	_, err := h.datastore.Put(ctx, k, link)