Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

refactor: wrapped errors #240

Open
scottd018 opened this issue Jan 5, 2022 · 2 comments
Open

refactor: wrapped errors #240

scottd018 opened this issue Jan 5, 2022 · 2 comments

Comments

@scottd018
Copy link
Contributor

scottd018 commented Jan 5, 2022

Define a consistent format for wrapping errors and defining errors.

Some thoughts on how to do this:

Option 1:

return nil, fmt.Errorf("%w; unable to convert resources object to string array", err)
unable to convert workload config spec.resources to []map[string]interface; [map[filename:/path/to/my/child-resources.yaml]]; unable to convert resources object to string array; unable to mutate configuration fields; error adding flags to `init-config collection` subcommand

Option 2:

return nil, fmt.Errorf("%w - unable to convert resources object to string array", err)
unable to convert workload config spec.resources to []map[string]interface - [map[filename:/path/to/my/child-resources.yaml]] - unable to convert resources object to string array - unable to mutate configuration fields; error adding flags to `init-config collection` subcommand

Option 3:

return nil, fmt.Errorf("%w, unable to convert resources object to string array", err)
unable to convert workload config spec.resources to []map[string]interface, [map[filename:/path/to/my/child-resources.yaml]], unable to convert resources object to string array, unable to mutate configuration fields; error adding flags to `init-config collection` subcommand

These obviously aren't the only options but are some of the patterns that I have found.

@scottd018
Copy link
Contributor Author

@JefeDavis I think you probably have a strong opinion on the pattern that we should follow, so interested in your suggestions here.

@JefeDavis
Copy link
Contributor

I prefer, fmt.Errorf("Unable to convert slice to string, %w", err)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants