refactor: use errors.Is()/errors.AsType() for error comparison and rename shadowed variables
Replace direct error equality checks (err == pgx.ErrNoRows, err != http.ErrServerClosed) with the idiomatic errors.Is() function throughout handlers, services, middleware, and app startup. This correctly handles wrapped error chains. Also replace a raw type assertion (*HTTPError) with errors.AsType[*HTTPError]() in the error handler middleware for consistency. Additionally, rename shadowed variables for clarity: - sidecar.go: config -> sidecarConfig, systemConfig (shadowed package-level vars) - media_scanner.go: uuid -> uuidString (shadowed the uuid package import)
This commit is contained in:
+2
-1
@@ -2,6 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -40,7 +41,7 @@ func (a *App) StartServer(addr string) error {
|
||||
|
||||
// Start HTTP server in background
|
||||
go func() {
|
||||
if err := a.server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
if err := a.server.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) {
|
||||
log.Fatalf("Server failed to start: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user