You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
515 B
31 lines
515 B
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
// Check errors and fail if they're bad
|
|
func check(err error) {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// Log weird errors for web stuff
|
|
func logError(w http.ResponseWriter, err error) {
|
|
if err != nil {
|
|
log.Println(err)
|
|
writeError(w, errorMessage{
|
|
StatusCode: http.StatusInternalServerError,
|
|
Msg: err.Error(),
|
|
})
|
|
}
|
|
}
|
|
|
|
// Check if a value exists and fail if it doesn't
|
|
func checkExists(exists bool, msg string) {
|
|
if !exists {
|
|
log.Fatal(msg)
|
|
}
|
|
}
|