Skip to content

Conversation

abourget
Copy link
Contributor

This PR enables wrapping (errors.As) of slack responses which contain rich error messages, e.g., indicating which blocks of position in the submitted JSON the error was found.

Solves #939

@abourget
Copy link
Contributor Author

Then users can do something like:

func enrichError(err error) error {
	var fullErr slack.SlackErrorResponse
	if errors.As(err, &fullErr) {
		err = fmt.Errorf("%s: %s", err.Error(), strings.Join(fullErr.ResponseMetadata.Messages, ", "))
	}
	return err
}

and simply decorate their err.

Copy link
Member

@kanata2 kanata2 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks :)

@kanata2 kanata2 merged commit 70970aa into slack-go:master Oct 30, 2021
ghost pushed a commit to range-labs/slack that referenced this pull request Apr 19, 2022
This is an exact copy of slack-go#990.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants