// Write a JSON error response. func writeError(lg *common.Logger, w http.ResponseWriter, errCode int, errStr string) { str := strings.Replace(errStr, `"`, `'`, -1) lg.Info(str + "\n") w.WriteHeader(errCode) w.Write([]byte(`{ "error" : "` + str + `"}`)) }
func createErrAndLog(lg *common.Logger, val string, level common.Level) error { lg.Write(level, val+"\n") return errors.New(val) }