Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

Error handling example in wiki documentation swallows warnings #95

Open
vjpr opened this issue Feb 2, 2017 · 0 comments
Open

Error handling example in wiki documentation swallows warnings #95

vjpr opened this issue Feb 2, 2017 · 0 comments

Comments

@vjpr
Copy link

vjpr commented Feb 2, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant