1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.aether.resolution;
12
13 import org.eclipse.aether.RepositoryException;
14
15
16
17
18 public class VersionResolutionException
19 extends RepositoryException
20 {
21
22 private final transient VersionResult result;
23
24
25
26
27
28
29 public VersionResolutionException( VersionResult result )
30 {
31 super( getMessage( result ), getCause( result ) );
32 this.result = result;
33 }
34
35 private static String getMessage( VersionResult result )
36 {
37 StringBuilder buffer = new StringBuilder( 256 );
38 buffer.append( "Failed to resolve version" );
39 if ( result != null )
40 {
41 buffer.append( " for " ).append( result.getRequest().getArtifact() );
42 if ( !result.getExceptions().isEmpty() )
43 {
44 buffer.append( ": " ).append( result.getExceptions().iterator().next().getMessage() );
45 }
46 }
47 return buffer.toString();
48 }
49
50 private static Throwable getCause( VersionResult result )
51 {
52 Throwable cause = null;
53 if ( result != null && !result.getExceptions().isEmpty() )
54 {
55 cause = result.getExceptions().get( 0 );
56 }
57 return cause;
58 }
59
60
61
62
63
64
65
66 public VersionResolutionException( VersionResult result, String message )
67 {
68 super( message, getCause( result ) );
69 this.result = result;
70 }
71
72
73
74
75
76
77
78
79 public VersionResolutionException( VersionResult result, String message, Throwable cause )
80 {
81 super( message, cause );
82 this.result = result;
83 }
84
85
86
87
88
89
90
91 public VersionResult getResult()
92 {
93 return result;
94 }
95
96 }