Skip to content

Wrap Go SDK errors w/ help blurb. - #3342

Merged
sipsma merged 1 commit into
dagger:mainfrom
sipsma:wrap-error
Oct 25, 2022
Merged

sipsma merged 1 commit into
dagger:mainfrom
sipsma:wrap-error

Conversation

@sipsma

@sipsma sipsma commented Oct 12, 2022

Copy link
Copy Markdown
Contributor

Signed-off-by: Erik Sipsma [email protected]

#3316

Need to update error message wrapper obviously once we decide exactly where we want to link to.

Did not just put this in engine.Start since we are planning on refactoring that out soon (cc @aluzzardi )

@netlify

netlify Bot commented Oct 12, 2022

Copy link
Copy Markdown

👷 Deploy request for cloak-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 6b0611cf72c8068049a3513df46c39b1b74aa348

@mircubed

Copy link
Copy Markdown
Contributor

#3350 will provide the URL needed to complete this PR

@sipsma

sipsma commented Oct 13, 2022

Copy link
Copy Markdown
Contributor Author

Just FYI this PR: #3349

may result in the need to also wrap the error returned by dagger.Connect. Should be trivial, just need to wrap that with the same func used in this PR.

Just mentioning in case that happens while I'm on PTO next week.

@sipsma sipsma mentioned this pull request Oct 13, 2022
8 tasks done
@sipsma
sipsma force-pushed the wrap-error branch 2 times, most recently from ebfe274 to 7d80732 Compare October 13, 2022 23:50
Comment thread sdk/go/dagger/error.go Outdated

@sipsma sipsma Oct 13, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated with the URL from here: https://github.com/dagger/dagger.io/pull/980#pullrequestreview-1141566520

Including the #go as suggested here: #3316 (comment)

Let me know if you agree with the phrasing here.

@sipsma
sipsma marked this pull request as ready for review October 14, 2022 15:37
@aluzzardi
aluzzardi changed the base branch from cloak to main October 14, 2022 18:25
@mircubed
mircubed requested a review from aluzzardi October 14, 2022 21:25
@mircubed

Copy link
Copy Markdown
Contributor

@aluzzardi @shykes can you take a moment to review and merge?

@sipsma

sipsma commented Oct 14, 2022

Copy link
Copy Markdown
Contributor Author

Have to fix something after the rebase on main, but let me know if the blurb needs any updates in the meantime

@sipsma
sipsma force-pushed the wrap-error branch 2 times, most recently from f8d9d76 to aa9eba7 Compare October 14, 2022 22:20
@sipsma

sipsma commented Oct 14, 2022

Copy link
Copy Markdown
Contributor Author

Updated, @aluzzardi wrapping the whole gql client just to annotate all errors is a little meh but it was an easy way to ensure that every use of it got the error wrapping (including direct use of Do and the query builder). It also avoided some annoying circular imports that were arising otherwise.

Happy to take a different approach if you think it's going to cause issues.

Comment thread sdk/go/dagger/client.go
func Connect(ctx context.Context, opts ...ClientOpt) (*Client, error) {
func Connect(ctx context.Context, opts ...ClientOpt) (_ *Client, rerr error) {
defer func() {
if rerr != nil {

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.

I fail to see where this rerr is set.
I will checkout the code and check my assumption and come back to this.

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.

I confirm that rerr is not set here.
Should we intercept any error in Connect and set rerr instead? Or just the c.conn.Connect(ctx, cfg)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I might be misunderstanding but rerr should be set whenever the second return val in non-nil anywhere in the func. E.g. https://go.dev/play/p/6vwRL72pmoV

Comment thread sdk/go/client.go
func Connect(ctx context.Context, opts ...ClientOpt) (_ *Client, rerr error) {
defer func() {
if rerr != nil {
rerr = withErrorHelp(rerr)

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.

Will this actually wrap the error in return nil, err? I thought everywhere had to assign rerr 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

🤯 neat

@sipsma
sipsma merged commit ba57a41 into dagger:main Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants