Skip to content

Commit 8bc25f6

Browse files
sokraTheLarkInn
authored andcommitted
add error for webpack#3556, add recommendations for errors (webpack#3563)
1 parent d751849 commit 8bc25f6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/RuleSet.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ RuleSet.normalizeRule = function(rule, refs) {
146146
}
147147

148148
if(rule.loader && rule.loaders)
149-
throw new Error("Provided loader and loaders for rule");
149+
throw new Error(RuleSet.buildErrorMessage(rule, new Error("Provided loader and loaders for rule (use only one of them)")));
150150

151151
var loader = rule.loaders || rule.loader;
152152
if(typeof loader === "string" && !rule.options && !rule.query) {
@@ -160,10 +160,12 @@ RuleSet.normalizeRule = function(rule, refs) {
160160
query: rule.query
161161
});
162162
} else if(loader && (rule.options || rule.query)) {
163-
throw new Error("options/query cannot be used with loaders");
163+
throw new Error(RuleSet.buildErrorMessage(rule, new Error("options/query cannot be used with loaders (use options for each array item)")));
164164
} else if(loader) {
165165
checkUseSource("loaders");
166166
newRule.use = RuleSet.normalizeUse(loader);
167+
} else if(rule.options || rule.query) {
168+
throw new Error(RuleSet.buildErrorMessage(rule, new Error("options/query provided without loader (use loader + options)")));
167169
}
168170

169171
if(rule.use) {
@@ -186,13 +188,13 @@ RuleSet.normalizeRule = function(rule, refs) {
186188

187189
function checkUseSource(newSource) {
188190
if(useSource && useSource !== newSource)
189-
throw new Error("Rule can only have one result source (provided " + newSource + " and " + useSource + ")");
191+
throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one result source (provided " + newSource + " and " + useSource + ")")));
190192
useSource = newSource;
191193
}
192194

193195
function checkResourceSource(newSource) {
194196
if(resourceSource && resourceSource !== newSource)
195-
throw new Error("Rule can only have one resource source (provided " + newSource + " and " + resourceSource + ")");
197+
throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one resource source (provided " + newSource + " and " + resourceSource + ")")));
196198
resourceSource = newSource;
197199
}
198200

0 commit comments

Comments
 (0)