docs icon indicating copy to clipboard operation
docs copied to clipboard

Error handling example in wiki documentation swallows warnings

Open vjpr opened this issue 8 years ago • 0 comments

From https://github.com/webpack/docs/wiki/node.js-api#error-handling

var webpack = require("webpack");
webpack({
    // configuration
}, function(err, stats) {
    if(err)
        return handleFatalError(err);
    var jsonStats = stats.toJson();
    if(jsonStats.errors.length > 0)
        // PREVENTS WARNINGS SHOWING
        return handleSoftErrors(jsonStats.errors);
    if(jsonStats.warnings.length > 0)
        handleWarnings(jsonStats.warnings);
    successfullyCompiled();
});

Warnings should be logged first, because some warning may be the cause of soft errors, for example "critical dependency warnings".

The return handleSoftErrors prevents warnings being shown.

vjpr avatar Feb 02 '17 09:02 vjpr