Error Output
The output of Microsoft Ajax Minifier conforms to the MSBuild/Visual Studio format for error and warning messages. In order for MSBuild to properly recognize and parse error messages in the stderr output stream, they must conform to this format:origin: [subcategory] category code: text
The origin section of the message is a required, non-localized indicator of where the error occurred. If the error is with the Microsoft Ajax Minifier tool itself (bad parameter, etc), then the origin will simply be the name of the tool (“ajaxmin.exe”). If the error is within one of the input source files, the file name will be source, followed by the line and column information:
path(line,columnstart-columnend)
The subcategory is spec’d as an optional localized modifier of the category field. Typically this field is used to indicate the severity of the error thrown.
The category field is required, contains one of two possible values, and is not localizable. The value can be either “error” or “warning.”
The code is a required non-localized code to further indicate the error that has occurred. It cannot contain any spaces. Code values for Microsoft Ajax Minifier will always begin with the prefixes “AM,” “JS,” or “CSS.” For example, should Microsoft Ajax Minifier encounter any IOException when reading or writing any files, the code will be “AM-IO.” Errors within a JavaScript source file will contain the internal error number, for example, JS1016 indicates an unterminated comment error.
The text field is an optional, localized string giving a human-readable description of the error that has occurred. It’s technically optional, but Microsoft Ajax Minifier will always include some description in this field.
With Microsoft Ajax Minifier conforming to this output format, if Microsoft Ajax Minifier is integrated into your build system, errors and warnings generated by Microsoft Ajax Minifier will appear in the proper error and warning panes, and double-clicking on the errors will take you to the appropriate point within the source file.
Some examples of Microsoft Ajax Minifier error strings:
- bar.js(2,5-10): run-time error JS1010: Expected identifier: while
- a.js(3,4-9): coding error JS1206: Did you intend to write an assignment here: a = 4
- a.js(2,5-13): code warning JS1137: 'abstract' is a new reserved word and should not be used as an identifier: abstract
- foo.js(9,56-57): performance warning JS1135: Variable 'i' has not been declared: i
- j.js(7,1-5): improper technique warning JS1267: Always use full statement blocks: else
- ajaxmin.exe: error AM-USAGE: Invalid switch: -9