-
Notifications
You must be signed in to change notification settings - Fork 293
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
import: improve err msg #2242
import: improve err msg #2242
Conversation
@@ -19,7 +19,7 @@ type CircularImportError struct { | |||
func importFile(filePath string) (*dslNode, error) { | |||
schemaBytes, err := os.ReadFile(filePath) | |||
if err != nil { | |||
return nil, fmt.Errorf("failed to read schema file: %w", err) | |||
return nil, fmt.Errorf("failed to read import in schema file: %w", err) |
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.
This is good, but we should also decorate it with the source location information from the source file(s) in which the import was used. It would require tracking them in the import context, but it should be doable.
Something like: failed to read import in schema file: %w; referenced at [...]
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.
done, tested with zed, it returns terminated with errors error="parse error in
simple.zed, line 2, column 1: failed to read import in schema file"
on a faulty import
I think the idea of this was that it'd include the information about where in the source it happened:
I think it'll require turning this error: https://github.com/authzed/spicedb/blob/main/pkg/composableschemadsl/compiler/importer.go#L21-L23 into a WithSourceError like this one: https://github.com/authzed/spicedb/blob/main/pkg/composableschemadsl/compiler/translator.go#L94-L96 and then pulling that change into zed. |
Now
does this look good? |
Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
bcdbe54
to
1777150
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.
This looks good to me now.
Fixes authzed/zed#463, error now explicitly reports that there is something wrong with the import