mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-10-09 16:53:59 +02:00
fix improve error message when browser start fails
Signed-off-by: RonniSkansing <rskansing@gmail.com>
This commit is contained in:
5 files changed
+104
-6
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user