playground: More verbose error message The existing error message when accessing a code snippet from an unknown country (App Engine detected as "ZZ") have been subject for confusion several times. I've seen many users thinking that the particular code snippet they are trying to access contains code that isn't legal to share, when it is only App Engine that fails to identify their origin. Most often this is because they are behind a proxy. This change gives a more helpful message. It is also formated in HTML as the previous used html.Error() that showed that message as text, verbatim. Change-Id: Idb8598f933bb46b79ea417310e965f3fa774f0ce Reviewed-on: https://go-review.googlesource.com/48930 Reviewed-by: Andrew Bonventre <andybons@golang.org>
diff --git a/app/goplay/edit.go b/app/goplay/edit.go index 0df15cc..5af8b1f 100644 --- a/app/goplay/edit.go +++ b/app/goplay/edit.go
@@ -37,8 +37,8 @@ snip := &Snippet{Body: []byte(hello)} if strings.HasPrefix(r.URL.Path, "/p/") { if !allowShare(r) { - msg := `<h1>Unavailable For Legal Reasons</h1><p>If you believe this is in error, please <a href="https://golang.org/issue">file an issue</a>.</p>` - http.Error(w, msg, http.StatusUnavailableForLegalReasons) + w.WriteHeader(http.StatusUnavailableForLegalReasons) + w.Write([]byte(`<h1>Unavailable For Legal Reasons</h1><p>Viewing and/or sharing code snippets is not available in your country for legal reasons. This message might also appear if your country is misdetected. If you believe this is an error, please <a href="https://golang.org/issue">file an issue</a>.</p>`)) return } c := appengine.NewContext(r)