untitled

(John Hannent) #1
Hoping for helpful error messages ..................................................

A really helpful error message would say specifically what the error is and
where it’s located. Finding the location of the error is often the biggest prob-
lem when debugging code.


At least the parser is correctly informing you that an error exists in either line
13, line 14, or both. That’s useful information, but actually the error is not in
either of these lines — just nearthem. The validator should be able to report
the precise location, specify the error itself, and provide a suggested cure. That
would be a truly helpful debugging utility.


The error in this code is common in languages like C and Java, and, thanks to
the CSS committees, it’s now unnecessarily common in CSS. A good error
message would be specific, like this:


Line 12 is missing an ending semicolon:

font-style: normal!Important

To fix this error, add a semicolon to the end of this line,
like this:

font-style: normal!Important;

Perhaps there’s hope that one day that the validator (debugger) and the
debuggers for other languages can actually be precise about a problem and
offer a suggested cure. (JavaScript is pretty weak in this area too, and most
languages have vague error messages and often point to the wrong location
in the code.)


In any case, if you add the semicolon to the line in the .css file and then rerun
the validation, you get this result (no error section this time):


W3C CSS Validator Results for file://localhost/C:\MyFirst.css
To work as intended, your CSS style sheet needs a correct
document parse tree. This means you should use
valid HTML.

Warnings
URI : file://localhost/C:\MyFirst.css

Line : 5 font-family: You are encouraged to offer a generic
family as a last alternative
Line : 11 font-family: You are encouraged to offer a generic
family as a last alternative

Chapter 17: Testing and Debugging 307

Free download pdf