straightened out error handling so we don't wind up with a bunch of panics clogging the debug console

This commit is contained in:
2026-02-22 23:04:49 -07:00
parent 7b40c04897
commit 4db82f63d5
4 changed files with 90 additions and 30 deletions
+17 -3
View File
@@ -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)
}