Skip to content

Commit

Permalink
Merge pull request #489 from MUzairS15/MUzairS15/fix
Browse files Browse the repository at this point in the history
Return `meshkit` styled error from `WriteToFile` function.
  • Loading branch information
MUzairS15 authored Apr 7, 2024
2 parents e96d72e + 22b0961 commit 48b6a54
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,17 @@ func IsClosed[K any](ch chan K) bool {
func WriteToFile(path string, content string) error {
file, err := os.Create(path)
if err != nil {
return err
return ErrCreateFile(err, path)
}

_, err = file.WriteString(content)
if err != nil {
return err
return ErrWriteFile(err, path)
}
// Close the file to save the changes.
err = file.Close()
if err != nil {
return err
return ErrWriteFile(err, path)
}
return nil
}
Expand Down

0 comments on commit 48b6a54

Please sign in to comment.