You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using importers in my project. Sometimes I need to raise an exception inside them because the path to a scss file is wrong. I want to show a simple message to my users that the file was not found. The problem is that libsass converts exception from importer to a string with full traceback. I don't want to show traceback to the user.
How can I get rid of the traceback? Can libsass throw a python exception instead of converting it to a string?
Example:
importsassdefimporter(path, prev):
raiseValueError(f"Oops, something is wrong with {path}")
try:
css=sass.compile(
string='@import "xxx";',
importers=[(0, importer)]
)
exceptsass.CompileErrorase:
# Display error to user:print("Error in Sass:", e)
Output:
Error in Sass: Error:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/sass.py", line 191, in inner
ret = func(path, prev)
^^^^^^^^^^^^^^^^
File "<ipython-input-15-a2aa58127f68>", line 2, in importer
raise ValueError(f"Oops, something is wrong with {path}")
ValueError: Oops, something is wrong with xxx
on line 1:9 of stdin
>> @import "xxx";
--------^
The text was updated successfully, but these errors were encountered:
I don't believe there's a way to do that -- in theory there could be some customization around returning a SassError and converting that into an import error -- but it doesn't look like that happens at the moment
I'm using importers in my project. Sometimes I need to raise an exception inside them because the path to a scss file is wrong. I want to show a simple message to my users that the file was not found. The problem is that libsass converts exception from importer to a string with full traceback. I don't want to show traceback to the user.
How can I get rid of the traceback? Can libsass throw a python exception instead of converting it to a string?
Example:
Output:
The text was updated successfully, but these errors were encountered: