diff --git a/internal/app/httpSrv/httpSrv.go b/internal/app/httpSrv/httpSrv.go index a6e4dcb..a106994 100644 --- a/internal/app/httpSrv/httpSrv.go +++ b/internal/app/httpSrv/httpSrv.go @@ -65,7 +65,7 @@ func New(log *slog.Logger, cfg *config.HTTPServerConfig, storage Storage, mediaS func (app *App) MustRun() { const op = "app.httpSrv.Stop" if err := app.srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { - app.log.Error("failed to start server", sl.Err(err)) + app.log.Error("failed to start server", slog.String("op", op), sl.Err(err)) panic(err) } app.log.Info("HTTP server stopped") @@ -76,7 +76,7 @@ func (app *App) Stop() { shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 30*time.Second) err := app.srv.Shutdown(shutdownCtx) if err != nil { - app.log.Error("failed to stop server", sl.Err(err)) + app.log.Error("failed to stop server", slog.String("op", op), sl.Err(err)) } shutdownCancel() } diff --git a/internal/http-server/handlers/recipeImage/recipeImage.go b/internal/http-server/handlers/recipeImage/recipeImage.go index 5974a85..ccc4bfb 100644 --- a/internal/http-server/handlers/recipeImage/recipeImage.go +++ b/internal/http-server/handlers/recipeImage/recipeImage.go @@ -44,6 +44,7 @@ func New(log *slog.Logger, imageProvider ImageProvider) http.HandlerFunc { err = renderObject(w, r, obj) if err != nil { log.Error("Fail on rendering object", sl.Err(err)) + render.JSON(w, r, resp.Error("cannot get file")) } } } diff --git a/internal/media_storage/minio/minio.go b/internal/media_storage/minio/minio.go index 73b9379..511f2e3 100644 --- a/internal/media_storage/minio/minio.go +++ b/internal/media_storage/minio/minio.go @@ -57,6 +57,8 @@ func (o *ObjStorage) getFile(ctx context.Context, bucketName string, objectName } // Delete file from bucket +// +//nolint:unused func (o *ObjStorage) delFile(ctx context.Context, bucketName string, objectName string) error { const op = "media_storage.minio.DelFile" err := o.minio.RemoveObject(ctx, bucketName, objectName, minio.RemoveObjectOptions{ForceDelete: true}) diff --git a/internal/storage/postgresql/postgresql.go b/internal/storage/postgresql/postgresql.go index 87e1d8c..a3e9567 100644 --- a/internal/storage/postgresql/postgresql.go +++ b/internal/storage/postgresql/postgresql.go @@ -38,7 +38,7 @@ func (s *Storage) AddRecipe(ctx context.Context, recipe models.Recipe) error { // refactor error handling // rollback transaction on return - defer tx.Rollback(ctx) + defer tx.Rollback(ctx) //nolint:errcheck var id uint // insert recipe