-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
2a3bbdc
to
0204352
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
backend/schema/errors.go
Outdated
Err error `protobuf:"-"` // Wrapped error, if any | ||
} | ||
|
||
func (e *Error) ToProto() *schemapb.Error { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
backend/schema/errors.go
Outdated
@@ -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 } |
There was a problem hiding this comment.
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.
go-runtime/compile/build.go
Outdated
return fmt.Errorf("failed to write errors: %w", err) | ||
} | ||
|
||
return fmt.Errorf("failed to extract module schema: %w", errors.Join(otherErrs...)) |
There was a problem hiding this comment.
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
0204352
to
0a64c47
Compare
This approach enables arbitrary runtimes to surface schema errors via proto. Go will use this approach for consistency across runtimes.
fixes #1207