added error logging into the SendError call
This commit is contained in:
parent
3ed33dfac9
commit
e2a686fb65
@ -1,6 +1,7 @@
|
|||||||
package servlet
|
package servlet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"geniuscartel.xyz/vinegar/vinegarUtil"
|
"geniuscartel.xyz/vinegar/vinegarUtil"
|
||||||
"log"
|
"log"
|
||||||
@ -72,7 +73,7 @@ func (s *VinegarServlet) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.SendError(w, req, 404, "Couldn't find your content.")
|
s.SendError(w, req, 404, "Couldn't find your content.", errors.New("failed to match route for ["+path+"]"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VinegarServlet) Start() {
|
func (s *VinegarServlet) Start() {
|
||||||
@ -95,8 +96,9 @@ func (r *VinegarRoute) Announce() {
|
|||||||
log.Printf("Added route for [%s]\n", r.Pattern.String())
|
log.Printf("Added route for [%s]\n", r.Pattern.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VinegarServlet) SendError(w http.ResponseWriter, req *http.Request, code int, msg string) {
|
func (s *VinegarServlet) SendError(w http.ResponseWriter, req *http.Request, code int, msg string, aErr error) {
|
||||||
fmt.Printf("[%d][%s]. Rendering template for code %d with message: %s\n", code, req.URL.Path, code, msg)
|
fmt.Printf("[%d][%s]. Rendering template for code %d with message: %s\n", code, req.URL.Path, code, msg)
|
||||||
|
fmt.Println(aErr)
|
||||||
tmpl, exists := s.ErrorRoutes[code]
|
tmpl, exists := s.ErrorRoutes[code]
|
||||||
if exists {
|
if exists {
|
||||||
tmpl.TemplateManager.AddMixin("code", strconv.Itoa(code))
|
tmpl.TemplateManager.AddMixin("code", strconv.Itoa(code))
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package servlet
|
package servlet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
util "geniuscartel.xyz/vinegar/vinegarUtil"
|
util "geniuscartel.xyz/vinegar/vinegarUtil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
@ -73,7 +74,7 @@ func createSingleFileServletFunction(route *FileRoute) VinegarHandlerFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
route.srv.SendError(w, req, 404, "File not found.")
|
route.srv.SendError(w, req, 404, "File not found.", errors.New("could not find file: "+route.fileRoot))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +115,7 @@ func createCompressibleFileServletFunction(route *FileRoute, basePattern string,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
route.srv.SendError(w, req, 404, "Couldn't find your content.")
|
route.srv.SendError(w, req, 404, "Couldn't find your content.", errors.New("could not find valid file at ["+resourcePath+"]"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +155,7 @@ func createUncompressedFileServletFunction(route *FileRoute, basePattern string,
|
|||||||
return
|
return
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
route.srv.SendError(w, req, 404, "Couldn't find your content.")
|
route.srv.SendError(w, req, 404, "Couldn't find your content.", errors.New("could not find file for ["+stub+"]"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fun
|
return fun
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user