Problem: error values are ignored
Solution: handle error values
This commit is contained in:
parent
67bc36bb66
commit
9c8cec2c5b
|
@ -326,6 +326,10 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
sessionVar := c.Value
|
sessionVar := c.Value
|
||||||
sess, err := loadSession(sessionVar, conn)
|
sess, err := loadSession(sessionVar, conn)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(w, "ERROR: %q\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
verified, authResponse, err := performIndieauthCallback(h.BaseURL, r, &sess)
|
verified, authResponse, err := performIndieauthCallback(h.BaseURL, r, &sess)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -353,6 +357,11 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
sessionVar := c.Value
|
sessionVar := c.Value
|
||||||
sess, err := loadSession(sessionVar, conn)
|
sess, err := loadSession(sessionVar, conn)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !isLoggedIn(h.Backend, &sess) {
|
if !isLoggedIn(h.Backend, &sess) {
|
||||||
w.WriteHeader(401)
|
w.WriteHeader(401)
|
||||||
|
@ -364,7 +373,17 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
page.Session = sess
|
page.Session = sess
|
||||||
currentChannel := r.URL.Query().Get("uid")
|
currentChannel := r.URL.Query().Get("uid")
|
||||||
page.Channels, err = h.Backend.ChannelsGetList()
|
page.Channels, err = h.Backend.ChannelsGetList()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
page.Feeds, err = h.Backend.FollowGetList(currentChannel)
|
page.Feeds, err = h.Backend.FollowGetList(currentChannel)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, v := range page.Channels {
|
for _, v := range page.Channels {
|
||||||
if v.UID == currentChannel {
|
if v.UID == currentChannel {
|
||||||
|
@ -409,6 +428,11 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
sessionVar := c.Value
|
sessionVar := c.Value
|
||||||
sess, err := loadSession(sessionVar, conn)
|
sess, err := loadSession(sessionVar, conn)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !isLoggedIn(h.Backend, &sess) {
|
if !isLoggedIn(h.Backend, &sess) {
|
||||||
w.WriteHeader(401)
|
w.WriteHeader(401)
|
||||||
|
@ -432,6 +456,11 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
sessionVar := c.Value
|
sessionVar := c.Value
|
||||||
sess, err := loadSession(sessionVar, conn)
|
sess, err := loadSession(sessionVar, conn)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !isLoggedIn(h.Backend, &sess) {
|
if !isLoggedIn(h.Backend, &sess) {
|
||||||
w.WriteHeader(401)
|
w.WriteHeader(401)
|
||||||
|
@ -442,6 +471,11 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
var page settingsPage
|
var page settingsPage
|
||||||
page.Session = sess
|
page.Session = sess
|
||||||
page.Channels, err = h.Backend.ChannelsGetList()
|
page.Channels, err = h.Backend.ChannelsGetList()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
// page.Feeds = h.Backend.Feeds
|
// page.Feeds = h.Backend.Feeds
|
||||||
|
|
||||||
err = h.renderTemplate(w, "settings.html", page)
|
err = h.renderTemplate(w, "settings.html", page)
|
||||||
|
@ -456,6 +490,11 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
sessionVar := getSessionCookie(w, r)
|
sessionVar := getSessionCookie(w, r)
|
||||||
|
|
||||||
sess, err := loadSession(sessionVar, conn)
|
sess, err := loadSession(sessionVar, conn)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !isLoggedIn(h.Backend, &sess) {
|
if !isLoggedIn(h.Backend, &sess) {
|
||||||
sess.NextURI = r.URL.String()
|
sess.NextURI = r.URL.String()
|
||||||
|
@ -502,6 +541,11 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
page.Scope = scope
|
page.Scope = scope
|
||||||
page.State = state
|
page.State = state
|
||||||
page.Channels, err = h.Backend.ChannelsGetList()
|
page.Channels, err = h.Backend.ChannelsGetList()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
app, err := getAppInfo(clientID)
|
app, err := getAppInfo(clientID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -172,6 +172,9 @@ func (h *hubIncomingBackend) Feeds() ([]Feed, error) {
|
||||||
inner join channels c on c.id = f.channel_id
|
inner join channels c on c.id = f.channel_id
|
||||||
where hub is not null
|
where hub is not null
|
||||||
`)
|
`)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var feed Feed
|
var feed Feed
|
||||||
|
|
|
@ -83,6 +83,11 @@ func (h *incomingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
feedContent, err := ioutil.ReadAll(r.Body)
|
feedContent, err := ioutil.ReadAll(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: %s\n", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// match signature
|
// match signature
|
||||||
sig := r.Header.Get("X-Hub-Signature")
|
sig := r.Header.Get("X-Hub-Signature")
|
||||||
|
|
|
@ -775,7 +775,10 @@ func WithCaching(pool *redis.Pool, ff fetch.Fetcher) fetch.Fetcher {
|
||||||
return nil, fmt.Errorf("error parsing %s as url: %s", fetchURL, err)
|
return nil, fmt.Errorf("error parsing %s as url: %s", fetchURL, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", u.String(), nil)
|
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
data, err := redis.Bytes(conn.Do("GET", cacheKey))
|
data, err := redis.Bytes(conn.Do("GET", cacheKey))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -821,7 +824,10 @@ func Fetch2(fetchURL string) (*http.Response, error) {
|
||||||
return nil, fmt.Errorf("error parsing %s as url: %s", fetchURL, err)
|
return nil, fmt.Errorf("error parsing %s as url: %s", fetchURL, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", u.String(), nil)
|
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
|
|
@ -48,6 +48,9 @@ func FeedHeader(fetcher Fetcher, fetchURL, contentType string, body io.Reader) (
|
||||||
md := microformats.Parse(resp.Body, u)
|
md := microformats.Parse(resp.Body, u)
|
||||||
|
|
||||||
author, ok = jf2.SimplifyMicroformatDataAuthor(md)
|
author, ok = jf2.SimplifyMicroformatDataAuthor(md)
|
||||||
|
if !ok {
|
||||||
|
log.Println("Could not simplify the author")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,9 @@ func simplifyContent(k string, v []interface{}) *microsub.Content {
|
||||||
// CleanHTML removes white-space:pre from html
|
// CleanHTML removes white-space:pre from html
|
||||||
func CleanHTML(s string) (string, error) {
|
func CleanHTML(s string) (string, error) {
|
||||||
doc, err := html.Parse(strings.NewReader(s))
|
doc, err := html.Parse(strings.NewReader(s))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
whitespaceRegex, err := regexp.Compile(`white-space:\s*pre`)
|
whitespaceRegex, err := regexp.Compile(`white-space:\s*pre`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user