Skip to content

Commit

Permalink
fix: improve error messages when failing to load yaml files (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyecusch authored Jul 25, 2024
1 parent efbd5ee commit 2a1ee8f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/project/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func ConfigurationFromFile(fs afero.Fs, filePath string) (*ProjectConfiguration,
info, err := fs.Stat(filePath)
if err != nil {
if os.IsNotExist(err) {
return nil, fmt.Errorf("nitric.yaml not found in %s. A nitric project is required to load configuration", absProjectDir)
return nil, fmt.Errorf("nitric.yaml not found in %s. Check that you are in the root directory of a nitric project", absProjectDir)
}

return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func fromProjectConfiguration(projectConfig *ProjectConfiguration, fs afero.Fs)
func FromFile(fs afero.Fs, filepath string) (*Project, error) {
projectConfig, err := ConfigurationFromFile(fs, filepath)
if err != nil {
return nil, fmt.Errorf("unable to load nitric.yaml, are you currently in a nitric project?: %w", err)
return nil, fmt.Errorf("error loading nitric.yaml: %w", err)
}

return fromProjectConfiguration(projectConfig, fs)
Expand Down
2 changes: 1 addition & 1 deletion pkg/project/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func configFromFile[T any](fs afero.Fs, filePath string) (*StackConfig[T], error
stackConfig := &StackConfig[T]{}

if err := yaml.Unmarshal(stackFileContents, stackConfig); err != nil {
return nil, err
return nil, fmt.Errorf("unable to parse stack file '%s': %w", filePath, err)
}

stackConfig.Name, err = GetStackNameFromFileName(filePath)
Expand Down

0 comments on commit 2a1ee8f

Please sign in to comment.