Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: issue 321 (Wrap Errors where applicable) #331

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package fuego
import (
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"net/http"
Expand Down Expand Up @@ -152,18 +151,18 @@ func (s *Server) saveOpenAPIToFile(jsonSpecLocalPath string, jsonSpec []byte) er

err := os.MkdirAll(jsonFolder, 0o750)
if err != nil {
return errors.New("error creating docs directory")
return fmt.Errorf("error creating docs directory: %w", err)
}

f, err := os.Create(jsonSpecLocalPath) // #nosec G304 (file path provided by developer, not by user)
if err != nil {
return errors.New("error creating file")
return fmt.Errorf("error creating file: %w", err)
}
defer f.Close()

_, err = f.Write(jsonSpec)
if err != nil {
return errors.New("error writing file ")
return fmt.Errorf("error writing file: %w", err)
}

s.printOpenAPIMessage("JSON file: " + jsonSpecLocalPath)
Expand Down
Loading