1 package org.apache.maven.usability;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.PluginConfigurationException;
23 import org.apache.maven.plugin.PluginParameterException;
24 import org.apache.maven.usability.diagnostics.DiagnosisUtils;
25 import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
26 import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
27
28 public class PluginConfigurationDiagnoser
29 implements ErrorDiagnoser
30 {
31 public boolean canDiagnose( Throwable error )
32 {
33 return DiagnosisUtils.containsInCausality( error, PluginConfigurationException.class );
34 }
35
36 public String diagnose( Throwable error )
37 {
38 PluginConfigurationException pce =
39 (PluginConfigurationException) DiagnosisUtils.getFromCausality( error, PluginConfigurationException.class );
40
41 if ( pce instanceof PluginParameterException )
42 {
43 PluginParameterException exception = (PluginParameterException) pce;
44
45 return exception.buildDiagnosticMessage();
46 }
47 else if ( DiagnosisUtils.containsInCausality( pce, ComponentConfigurationException.class ) )
48 {
49 ComponentConfigurationException cce = (ComponentConfigurationException) DiagnosisUtils.getFromCausality(
50 pce, ComponentConfigurationException.class );
51
52 return pce.buildConfigurationDiagnosticMessage( cce );
53 }
54 else
55 {
56 return pce.getMessage();
57 }
58 }
59 }