~yerinalexey/gobin

1a7289c18cb6805c329dbe1ba664e49f40cd34e2 — Alexey Yerin 11 months ago 43023ba
fix: return 500 if database request fails
1 files changed, 6 insertions(+), 0 deletions(-)

M main.go
M main.go => main.go +6 -0
@@ 71,6 71,9 @@ func main() {

		if err != nil {
			log.Printf("Failed to get paste list: %v\n", err)

			w.WriteHeader(500)
			return
		}

		tmpl.ExecuteTemplate(w, "home", pastes)


@@ 91,6 94,9 @@ func main() {
			// Not Fatalf because nobody wants server to crash when database
			// insert fails
			log.Printf("Failed to submit paste: %v\n", err)

			w.WriteHeader(500)
			return
		}

		link := fmt.Sprintf("%s/paste/%d", base_url, id)