Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions cmd/docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func runDocGenCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
return slackerror.New(slackerror.ErrDocumentationGenerationFailed).WithRootCause(err)
}

// Generate errors reference
// Generate errors reference sorted alphabetically by error code
file, err := clients.Fs.Create(filepath.Join(docsDirPath, "errors.md"))
if err != nil {
return err
Expand All @@ -118,7 +118,14 @@ func runDocGenCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
if err != nil {
return err
}
err = tmpl.Execute(file, slackerror.ErrorCodeMap)
errors := make([]slackerror.Error, 0, len(slackerror.ErrorCodeMap))
for _, e := range slackerror.ErrorCodeMap {
errors = append(errors, e)
}
slices.SortFunc(errors, func(a, b slackerror.Error) int {
return strings.Compare(a.Code, b.Code)
})
err = tmpl.Execute(file, errors)
Comment on lines +121 to +128
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the errors are already sorted do we need this? Or are go Maps unordered?

if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/docgen/errors.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ones, as well as a list of the errors the Slack CLI may raise, what they mean,
and some ways to remediate them.

## Slack CLI errors list
{{range $key, $err := . }}
{{range $err := . }}
### {{ $err.Code }} {#{{ $err.Code }}}
{{ if $err.Message }}
**Message**: {{ $err.Message }}
Expand Down
Loading
Loading