change error handling

This commit is contained in:
yyasha 2024-01-27 21:58:35 +03:00
parent 825957a1e9
commit efee9b2718
1 changed files with 4 additions and 1 deletions

View File

@ -234,7 +234,10 @@ func GetRecipe(r *models.Recipe, ps pictureSaver, rs recipeSaver, rp recipeProvi
})
// check recipe exists
ex, err := rp.RecipeExists(context.Background(), r.Title) // interface!
if err != nil || ex {
if err != nil {
return fmt.Errorf("%s: %w", op, err)
}
if ex {
return fmt.Errorf("%s: %w", op, ErrRecipeExists)
}
// save picture