-
Notifications
You must be signed in to change notification settings - Fork 465
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
Improve API (sourceRoot option and importer errors) #915
Conversation
👍 💯 |
@mgreter, since the implementer doesn't have any context to resolve line and column information in importer, wouldn't it make sense that libsass handle those two at its own and just accept the error message? |
The implementor could have a context, like testing if the content it is loading conforms to the rules it expects. IMO it could give more details where the actual error occurred, so I'm not really convinced to remove it. But you may be right that it is a bit over engineered. I guess it's no harm in leaving it in for now? |
It works, awesome @mgreter ! So I'm trying to understand your discussion about context. Right now, libsass expects the implementor passes along the error line number/column. Would it be possible to provide error line number of where the @import line is? If that's already being passed, apologies for missing that. I'm asking if
|
Allow custom importer to return an error. We just extend the Import_Entry struct with error flags, since we can re-use at least the path from the existing object.
0f72f88
to
29d19d8
Compare
I added a switch, so if you set line and col to
|
Can size_t be negative? I'm getting an error assigning -1.
|
Then you probably need to use |
I think its not mandatory to return custom importer error for implementer. If you don't need the customized error, you can exclude it and libsass will fallback to its default missing-import error. |
@am11 the error isn't mandatory, but returning any non-empty entry list uses that as the missing import. Returning an empty list or size 1 with nothing in it, results in a runtime exception. So I'm returning an error to override the blank import entry that seems to be required to do this. Here's the code, if there's a better way to do it: https://github.com/wellington/wellington/blob/importer/context/export.go#L41 |
You could return a list with one entry, where you only set the filename (no data). Libsass will then try to load that file through it's loading code, which would emit the error @am11 probably meant. But IMO you should only do that if you are sure the file does not exist, otherwise it could have strange side effects! |
I'm not great at C, what do I pass to sass_make_import_entry() to do that? On Sat, Mar 7, 2015 at 12:03 PM Marcel Greter [email protected]
|
sass_make_import_entry("non_existing_file", 0, 0); |
Thanks for your patience, it's working great. Sending
|
Addresses #880 (//CC @chriseppstein)
I opted to extend the internal struct to also carry error options.
To return a error from custom importers you need to:
It will then throw an error as with regular imports that fail.