Конвенция для обработки ошибок + рефакторинг кода

This commit is contained in:
av
2026-06-28 21:22:12 +03:00
parent c6daba46d9
commit 3d5df62d62
14 changed files with 265 additions and 51 deletions
+3
View File
@@ -102,6 +102,9 @@ VALUES (?, ?, ?, ?, ?, ?)`
func (s *Store) GetDownload(ctx context.Context, id int64) (*Download, error) {
var d Download
if err := s.DB.GetContext(ctx, &d, `SELECT * FROM download WHERE id = ?`, id); err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, fmt.Errorf("get download %d: %w", id, ErrNotFound)
}
return nil, fmt.Errorf("get download %d: %w", id, err)
}
return &d, nil