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.profiles.activation.ProfileActivationException; |
23 | |
import org.apache.maven.usability.diagnostics.DiagnosisUtils; |
24 | |
import org.apache.maven.usability.diagnostics.ErrorDiagnoser; |
25 | |
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; |
26 | |
|
27 | 0 | public class ProfileActivationDiagnoser |
28 | |
implements ErrorDiagnoser |
29 | |
{ |
30 | |
|
31 | |
public boolean canDiagnose( Throwable error ) |
32 | |
{ |
33 | 0 | return DiagnosisUtils.containsInCausality( error, ProfileActivationException.class ); |
34 | |
} |
35 | |
|
36 | |
public String diagnose( Throwable error ) |
37 | |
{ |
38 | 0 | ProfileActivationException activationException = |
39 | |
(ProfileActivationException) DiagnosisUtils.getFromCausality( error, ProfileActivationException.class ); |
40 | |
|
41 | 0 | StringBuffer messageBuffer = new StringBuffer(); |
42 | |
|
43 | 0 | messageBuffer.append( "Error activating profiles." ); |
44 | 0 | messageBuffer.append( "\n\nReason: " ).append( activationException.getMessage() ); |
45 | |
|
46 | 0 | if ( DiagnosisUtils.containsInCausality( activationException, ComponentLookupException.class ) ) |
47 | |
{ |
48 | 0 | ComponentLookupException cle = (ComponentLookupException) DiagnosisUtils.getFromCausality( |
49 | |
activationException, ComponentLookupException.class ); |
50 | |
|
51 | 0 | messageBuffer.append( "\n\nThere was a problem retrieving one or more profile activators." ); |
52 | 0 | messageBuffer.append( "\n" ).append( cle.getMessage() ); |
53 | |
} |
54 | |
|
55 | 0 | messageBuffer.append( "\n" ); |
56 | |
|
57 | 0 | return messageBuffer.toString(); |
58 | |
} |
59 | |
|
60 | |
} |