added glob matching
This commit is contained in:
@@ -17,13 +17,13 @@ func throwError(
|
||||
statusCode int,
|
||||
msg string,
|
||||
err error,
|
||||
level string,
|
||||
level hws.ErrorLevel,
|
||||
) {
|
||||
err = s.ThrowError(w, r, hws.HWSError{
|
||||
StatusCode: statusCode,
|
||||
Message: msg,
|
||||
Error: err,
|
||||
Level: hws.ErrorLevel(level),
|
||||
Level: level,
|
||||
RenderErrorPage: true, // throw* family always renders error pages
|
||||
})
|
||||
if err != nil {
|
||||
@@ -39,7 +39,7 @@ func throwInternalServiceError(
|
||||
msg string,
|
||||
err error,
|
||||
) {
|
||||
throwError(s, w, r, http.StatusInternalServerError, msg, err, "error")
|
||||
throwError(s, w, r, http.StatusInternalServerError, msg, err, hws.ErrorERROR)
|
||||
}
|
||||
|
||||
// throwServiceUnavailable handles 503 errors
|
||||
@@ -50,7 +50,7 @@ func throwServiceUnavailable(
|
||||
msg string,
|
||||
err error,
|
||||
) {
|
||||
throwError(s, w, r, http.StatusServiceUnavailable, msg, err, "error")
|
||||
throwError(s, w, r, http.StatusServiceUnavailable, msg, err, hws.ErrorERROR)
|
||||
}
|
||||
|
||||
// throwBadRequest handles 400 errors (malformed requests)
|
||||
@@ -61,7 +61,7 @@ func throwBadRequest(
|
||||
msg string,
|
||||
err error,
|
||||
) {
|
||||
throwError(s, w, r, http.StatusBadRequest, msg, err, "debug")
|
||||
throwError(s, w, r, http.StatusBadRequest, msg, err, hws.ErrorDEBUG)
|
||||
}
|
||||
|
||||
// throwForbidden handles 403 errors (normal permission denials)
|
||||
@@ -72,7 +72,7 @@ func throwForbidden(
|
||||
msg string,
|
||||
err error,
|
||||
) {
|
||||
throwError(s, w, r, http.StatusForbidden, msg, err, "debug")
|
||||
throwError(s, w, r, http.StatusForbidden, msg, err, hws.ErrorDEBUG)
|
||||
}
|
||||
|
||||
// throwForbiddenSecurity handles 403 errors for security events (uses WARN level)
|
||||
@@ -83,7 +83,7 @@ func throwForbiddenSecurity(
|
||||
msg string,
|
||||
err error,
|
||||
) {
|
||||
throwError(s, w, r, http.StatusForbidden, msg, err, "warn")
|
||||
throwError(s, w, r, http.StatusForbidden, msg, err, hws.ErrorWARN)
|
||||
}
|
||||
|
||||
// throwUnauthorized handles 401 errors (not authenticated)
|
||||
@@ -94,7 +94,7 @@ func throwUnauthorized(
|
||||
msg string,
|
||||
err error,
|
||||
) {
|
||||
throwError(s, w, r, http.StatusUnauthorized, msg, err, "debug")
|
||||
throwError(s, w, r, http.StatusUnauthorized, msg, err, hws.ErrorDEBUG)
|
||||
}
|
||||
|
||||
// throwUnauthorizedSecurity handles 401 errors for security events (uses WARN level)
|
||||
@@ -105,7 +105,7 @@ func throwUnauthorizedSecurity(
|
||||
msg string,
|
||||
err error,
|
||||
) {
|
||||
throwError(s, w, r, http.StatusUnauthorized, msg, err, "warn")
|
||||
throwError(s, w, r, http.StatusUnauthorized, msg, err, hws.ErrorWARN)
|
||||
}
|
||||
|
||||
// throwNotFound handles 404 errors
|
||||
@@ -117,7 +117,7 @@ func throwNotFound(
|
||||
) {
|
||||
msg := fmt.Sprintf("The requested resource was not found: %s", path)
|
||||
err := errors.New("Resource not found")
|
||||
throwError(s, w, r, http.StatusNotFound, msg, err, "debug")
|
||||
throwError(s, w, r, http.StatusNotFound, msg, err, hws.ErrorDEBUG)
|
||||
}
|
||||
|
||||
// ErrorDetails contains structured error information for WebSocket error modals
|
||||
|
||||
Reference in New Issue
Block a user