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

feat: produce errors.pb during go schema extraction #1226

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

worstell
Copy link
Contributor

This approach enables arbitrary runtimes to surface schema errors via proto. Go will use this approach for consistency across runtimes.

fixes #1207

@alecthomas alecthomas mentioned this pull request Apr 10, 2024
@worstell worstell force-pushed the worstell/20240410-errorspb-go branch from 2a3bbdc to 0204352 Compare April 10, 2024 18:15
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Awesome!

Err error `protobuf:"-"` // Wrapped error, if any
}

func (e *Error) ToProto() *schemapb.Error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a Node? Possibly not? If it is though, this should return a proto.Message to comply with that interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not, I went back and forth but since it's not actually an element of the schema it felt a little conceptually weird to make it a node. i don't feel strongly though

@@ -43,7 +65,7 @@ func ErrorListFromProto(e *schemapb.ErrorList) *ErrorList {
}

func (e Error) Error() string { return fmt.Sprintf("%s-%d: %s", e.Pos, e.EndColumn, e.Msg) }
func (e Error) Unwrap() error { return e.Err }
func (e Error) Unwrap() error { return nil }
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is unused, just remove it completely - it's an optional interface.

return fmt.Errorf("failed to write errors: %w", err)
}

return fmt.Errorf("failed to extract module schema: %w", errors.Join(otherErrs...))
Copy link
Collaborator

Choose a reason for hiding this comment

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

If otherErrs is empty this will return a weird error, but also doesn't this conflict with the logic above where we only load the errors.pb if this function returns an error? Maybe we want to return the original err here instead?

This approach enables arbitrary runtimes to surface schema errors via proto. Go will use this approach for consistency across runtimes.

fixes #1207
@worstell worstell force-pushed the worstell/20240410-errorspb-go branch from 0204352 to 0a64c47 Compare April 11, 2024 18:23
@worstell worstell merged commit 8fef5ab into main Apr 11, 2024
12 checks passed
@worstell worstell deleted the worstell/20240410-errorspb-go branch April 11, 2024 18:27
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.

produce errors.pb in go
2 participants