Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow wrapping of error metadata. #990

Merged
merged 1 commit into from
Oct 30, 2021
Merged

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