Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review TreeWalker.setupChild method for exceptional cases #4814

Closed
romani opened this Issue Jul 24, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@romani
Copy link
Member

romani commented Jul 24, 2017

taken from #4755 (comment)

We need to review exception processing and make sure we deliver to user all context details if exception happen.

@rnveach

This comment has been minimized.

Copy link
Member

rnveach commented Feb 20, 2019

Original post was about adding a new try/catch to TreeWalker.setupChild.
#4755 (comment)

I still think we should do this, but to prevent saying the module name multiple times I think we should remove the module name from AutomaticBean.

final String message = String.format(Locale.ROOT,
"Cannot set property '%s' to '%s' in module %s", key, value, moduleName);
throw new CheckstyleException(message, ex);
}
catch (final IllegalArgumentException | ConversionException ex) {
final String message = String.format(Locale.ROOT, "illegal value '%s' for property "
+ "'%s' of module %s", value, key, moduleName);
.
It is just going to duplicate the work that TreeWalker/Checker will do.

Example:

com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - cannot initialize module com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck - Cannot set property 'file' to 'https://UnableToLoadThisURL' in module com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck
	at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:473)
	at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:198)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.createChecker(AbstractModuleTestSupport.java:137)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.createChecker(AbstractModuleTestSupport.java:118)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.verify(AbstractModuleTestSupport.java:220)
	at com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheckTest.testUrlInFilePropertyUnableToLoad(ImportControlCheckTest.java:329)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck - Cannot set property 'file' to 'https://UnableToLoadThisURL' in module com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck
	at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:162)
	at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:198)
	at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:468)
	... 30 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Cannot set property 'file' to 'https://UnableToLoadThisURL' in module com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck
	at com.puppycrawl.tools.checkstyle.api.AutomaticBean.tryCopyProperty(AutomaticBean.java:238)
	at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:191)
	at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:158)
	... 32 more
Caused by: java.lang.reflect.InvocationTargetException
@rnveach

This comment has been minimized.

Copy link
Member

rnveach commented Feb 23, 2019

Change was merged

@rnveach rnveach closed this Feb 23, 2019

@rnveach rnveach added this to the 8.18 milestone Feb 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.