1 package org.apache.maven.usability; 2 3 18 19 import org.apache.maven.artifact.manager.WagonManager; 20 import org.apache.maven.artifact.resolver.ArtifactNotFoundException; 21 import org.apache.maven.usability.diagnostics.DiagnosisUtils; 22 import org.apache.maven.usability.diagnostics.ErrorDiagnoser; 23 24 public class ArtifactNotFoundDiagnoser 25 implements ErrorDiagnoser 26 { 27 28 private WagonManager wagonManager; 29 30 public boolean canDiagnose( Throwable error ) 31 { 32 return DiagnosisUtils.containsInCausality( error, ArtifactNotFoundException.class ); 33 } 34 35 public String diagnose( Throwable error ) 36 { 37 ArtifactNotFoundException exception = 38 (ArtifactNotFoundException) DiagnosisUtils.getFromCausality( error, ArtifactNotFoundException.class ); 39 40 StringBuffer message = new StringBuffer (); 41 42 message.append( "Failed to resolve artifact.\n" ); 43 message.append( "\nGroupId: " ).append( exception.getGroupId() ); 44 message.append( "\nArtifactId: " ).append( exception.getArtifactId() ); 45 message.append( "\nVersion: " ).append( exception.getVersion() ); 46 message.append( "\n\n" ); 47 message.append( "Reason: " ).append( exception.getMessage() ); 48 49 if ( !wagonManager.isOnline() ) 50 { 51 message.append( "\n" ).append( SystemWarnings.getOfflineWarning() ); 52 } 53 54 message.append( "\n" ); 55 56 return message.toString(); 57 } 58 59 } 60 | Popular Tags |