fix(response): add nil check for c.Request in error logging
Prevents panic when ErrorFrom is called in test contexts where gin.CreateTestContext doesn't set up an HTTP request. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -77,7 +77,7 @@ func ErrorFrom(c *gin.Context, err error) bool {
|
||||
statusCode, status := infraerrors.ToHTTP(err)
|
||||
|
||||
// Log internal errors with full details for debugging
|
||||
if statusCode >= 500 {
|
||||
if statusCode >= 500 && c.Request != nil {
|
||||
log.Printf("[ERROR] %s %s\n Error: %s", c.Request.Method, c.Request.URL.Path, err.Error())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user