Skip to content

Commit 07ee452

Browse files
vogellaclaude
authored andcommitted
Enhance stack trace information for rule conflicts in BuildManager
Fixes #2278 When a builder attempts to begin or end a scheduling rule that doesn't match the outer scope rule, the error message now includes: - Builder name and label - Builder class name - Plugin ID - Project name - The conflicting rule This makes it much easier to identify which builder is causing the rule mismatch, especially in complex build scenarios with multiple builders. The enhancement catches IllegalArgumentException at the point where beginRule() and endRule() are called in BuildManager.basicBuild() and wraps it with detailed context before re-throwing.
1 parent 3e8e40e commit 07ee452

File tree

1 file changed

+46
-2
lines changed
  • resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events

1 file changed

+46
-2
lines changed

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,29 @@ private void basicBuild(int trigger, IncrementalProjectBuilder builder, Map<Stri
288288
depth = getWorkManager().beginUnprotected();
289289
// Acquire the rule required for running this builder
290290
if (rule != null) {
291-
Job.getJobManager().beginRule(rule, monitor);
291+
try {
292+
Job.getJobManager().beginRule(rule, monitor);
293+
} catch (IllegalArgumentException e) {
294+
// Enhance the error message with builder and project context
295+
String builderLabel = currentBuilder.getLabel();
296+
String builderClass = currentBuilder.getClass().getName();
297+
String projectName = builder.getProject().getFullPath().toString();
298+
String pluginId = currentBuilder.getPluginId();
299+
300+
String enhancedMessage = String.format(
301+
"Rule conflict in builder '%s' (class: %s, plugin: %s) for project '%s'. " + //$NON-NLS-1$
302+
"The builder requested rule '%s' which conflicts with the outer scope rule. " + //$NON-NLS-1$
303+
"Original error: %s", //$NON-NLS-1$
304+
builderLabel != null ? builderLabel : "<unknown>", //$NON-NLS-1$
305+
builderClass,
306+
pluginId != null ? pluginId : "<unknown>", //$NON-NLS-1$
307+
projectName,
308+
rule,
309+
e.getMessage()
310+
);
311+
312+
throw new IllegalArgumentException(enhancedMessage, e);
313+
}
292314
// Now that we've acquired the rule, changes may have been made concurrently, ensure we're pointing at the
293315
// correct currentTree so delta contains concurrent changes made in areas guarded by the scheduling rule
294316
if (currentTree != null) {
@@ -303,7 +325,29 @@ private void basicBuild(int trigger, IncrementalProjectBuilder builder, Map<Stri
303325
getWorkManager().endUnprotected(depth);
304326
}
305327
if (rule != null) {
306-
Job.getJobManager().endRule(rule);
328+
try {
329+
Job.getJobManager().endRule(rule);
330+
} catch (IllegalArgumentException e) {
331+
// Enhance the error message with builder and project context
332+
String builderLabel = currentBuilder.getLabel();
333+
String builderClass = currentBuilder.getClass().getName();
334+
String projectName = builder.getProject().getFullPath().toString();
335+
String pluginId = currentBuilder.getPluginId();
336+
337+
String enhancedMessage = String.format(
338+
"Rule conflict when ending rule for builder '%s' (class: %s, plugin: %s) for project '%s'. " + //$NON-NLS-1$
339+
"The builder tried to end rule '%s' which does not match the current scope. " + //$NON-NLS-1$
340+
"Original error: %s", //$NON-NLS-1$
341+
builderLabel != null ? builderLabel : "<unknown>", //$NON-NLS-1$
342+
builderClass,
343+
pluginId != null ? pluginId : "<unknown>", //$NON-NLS-1$
344+
projectName,
345+
rule,
346+
e.getMessage()
347+
);
348+
349+
throw new IllegalArgumentException(enhancedMessage, e);
350+
}
307351
}
308352
// Be sure to clean up after ourselves.
309353
if (clean || currentBuilder.wasForgetStateRequested()) {

0 commit comments

Comments
 (0)