fix improve error message when browser start fails

Signed-off-by: RonniSkansing <rskansing@gmail.com>
This commit is contained in:
RonniSkansing committed 2026-09-15 19:38:02 +02:00
1 parent b86c3c6731
commit 020ad9d468
5 files changed
+104 -6

No files matched your search

+23
View File
@@ -156,6 +156,12 @@ func (c *Common) handleErrors(
)
return false
}
if ok := handleOperationalError(g, c.Response, err); !ok {
c.Logger.Errorw("operational error",
"error", err,
)
return false
}
if ok := handleDBRowNotFound(g, c.Response, err); !ok {
c.Logger.Debugw("DB row not found error",
"error", err,
@@ -308,6 +314,23 @@ func handleCustomError(
return true
}
// handleOperationalError responds with a 500 that carries the safe message
// from an OperationalError. The full cause is logged by the caller. It is used
// for environment failures such as a blocked download or a browser that will
// not start, so the operator sees what went wrong instead of a generic error.
func handleOperationalError(
g *gin.Context,
responseHandler api.JSONResponseHandler,
err error,
) bool {
var opErr errs.OperationalError
if errors.As(err, &opErr) {
responseHandler.ServerErrorMessage(g, opErr.PublicMessage())
return false
}
return true
}
// handleServerError checks if the error is a server error
// if it is, a 500 response is sent
// if it is not, true is returned