-
This commit is contained in:
@ -146,6 +146,28 @@ func (eh *ErrorHandler) HandleInternalError(c *gin.Context, err error) {
|
||||
c.JSON(http.StatusInternalServerError, response)
|
||||
}
|
||||
|
||||
// HandleNotFoundError handles resource not found errors
|
||||
func (eh *ErrorHandler) HandleNotFoundError(c *gin.Context, resource string, message string) {
|
||||
requestID := eh.getOrGenerateRequestID(c)
|
||||
|
||||
eh.logger.Warn("Resource not found",
|
||||
zap.String("request_id", requestID),
|
||||
zap.String("resource", resource),
|
||||
zap.String("path", c.Request.URL.Path),
|
||||
zap.String("method", c.Request.Method),
|
||||
zap.String("remote_addr", c.ClientIP()),
|
||||
)
|
||||
|
||||
response := SecureErrorResponse{
|
||||
Error: "resource_not_found",
|
||||
Message: message,
|
||||
RequestID: requestID,
|
||||
Code: http.StatusNotFound,
|
||||
}
|
||||
|
||||
c.JSON(http.StatusNotFound, response)
|
||||
}
|
||||
|
||||
// determineErrorResponse determines the appropriate HTTP status and error type
|
||||
func (eh *ErrorHandler) determineErrorResponse(err error) (int, string) {
|
||||
if appErr, ok := err.(*AppError); ok {
|
||||
|
||||
Reference in New Issue
Block a user