straightened out error handling so we don't wind up with a bunch of panics clogging the debug console
This commit is contained in:
@@ -11,6 +11,7 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"git.erbosoft.com/amy/amsterdam/ui"
|
||||
@@ -42,7 +43,6 @@ var EPARAM error = errors.New("no parameters specified")
|
||||
* Returns:
|
||||
* Command string dictating what to be rendered.
|
||||
* Data as a parameter for the command string.
|
||||
* Standard Go error status.
|
||||
*/
|
||||
func NotImplPage(ctxt ui.AmContext) (string, any) {
|
||||
ctxt.SetLeftMenu("top")
|
||||
@@ -51,17 +51,31 @@ func NotImplPage(ctxt ui.AmContext) (string, any) {
|
||||
return "framed", "notimpl.jet"
|
||||
}
|
||||
|
||||
/* AmNotFoundHandler handles all paths that are "not found" in the application.
|
||||
* Parameters:
|
||||
* ctxt - The AmContext for the request.
|
||||
* Returns:
|
||||
* Command string dictating what to be rendered.
|
||||
* Data as a parameter for the command string.
|
||||
*/
|
||||
func AmNotFoundHandler(ctxt ui.AmContext) (string, any) {
|
||||
log.Infof("-> AmNotFoundHandler on path %s", ctxt.URLPath())
|
||||
return "error", fmt.Errorf("Path not found: %s", ctxt.URLPath())
|
||||
}
|
||||
|
||||
/* AmErrorHandler handles all the mundane HTTP errors generated by the Echo engine.
|
||||
* Parameters:
|
||||
* err - The error to be handled.
|
||||
* c - The Echo context error is being handled on.
|
||||
*/
|
||||
func AmErrorHandler(err error, c echo.Context) {
|
||||
log.Infof("-> AmErrorHandler on path %s", c.Request().URL.Path)
|
||||
if c.Response().Committed {
|
||||
return
|
||||
}
|
||||
amctxt := ui.AmContextFromEchoContext(c)
|
||||
cerr := ui.AmSendPageData(c, amctxt, "error", err)
|
||||
cerr := ui.AmWithTempContext(c, func(ctxt ui.AmContext) (string, any) {
|
||||
return "error", err
|
||||
})
|
||||
if cerr != nil {
|
||||
log.Errorf("Error rendering error (%v): %v", err, cerr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user