I have an invalid CSS like
body { font-family: 'Liberatio Sans', Roboto, Arimo, Arial, sans-serif; line-height: 1.5; }
As a result I received
null [2:16] Fehler in Ausdruck. (Ungültiger Token "\'". Erwartet wurde einer von: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <CH>, <VW>, <VH>, <VMIN>, <VMAX>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_ IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION_CALC>, <FUNCTION_VAR>, <FUNCTION>, "p rogid:".)
It took me quite a while to realize that the CR in the font-family was not valid. I didn't know where the error was originated. I would highly appreciate if the error message would include the element and the attribute, i.e. something like
body => font-family caused ....
Anonymous
The 2:16 mean that the Error is in Line 2 Character 16 so i believe the Error Message ist quite detailed
well - agreed 😊 if I understand the magic numbers 2:16. but why not make it more explicit, i.e
i have a SQL editor mentioning only the position - when all lines are concatenated. I never know where the error is since i have no clue how the string internally looks like and if there is some additional formatting done. therefore I don't really trust chars positions.
anyway - if you think the magic of 2:16 is broadly understood outside the developers of CSS parser thank I'm happy. At least I understand it now better.
Just a tiny remark to my last one:
We want to use the CSSparser in our project since it looks very, very promising. Since we have different libs included an exception is always hard to track if one doesn't know the source.
In my scenario I didn't know if the Error was raised by Jsoup or CSSparser. So my suggestion would be:
Last edit: LeO 2021-08-17
Hi LeO,
thanks for you interest in CSSParser and the bug report.
The error messages are more or less generic because CSSParser uses JavaCC for the parser construction. Will have a look if i can make at least the numbers more obvious.
BTW: there is a bit mor 'modern' version of the CSSParser used by HtmlUnit available at https://github.com/HtmlUnit/htmlunit-cssparser.
If i can find a way to improve the error msg i will implement it for both.
There is some documentation about customizing the error handling- see http://cssparser.sourceforge.net/gettingStarted.html
Can you please check if this does the job for you - CSSParseException has getColumnNumber()
getLineNumber() and getURI() as additional properties to CSSException.
Hi RBRi,
the link with the HTML-Unit works - if I remove the dot in the link :-) Anyway - this raises the first question: Which one to use? Either here from Sourceforge or the one from Github?
About the message: Yeah the hint to the customized error eases the pain; but the URI remains null. If the URI would provide at least the attribute-name than it would be quite usable.
thx
Any updates or insights about what version to use? Especially since the version numbers have a big difference. Is this verison here on Sourceforge still an actively developed one or does the focus shift to the github version?
It would be great to get at least an idea. Thx