@@ -22,6 +22,10 @@ type SolveError interface {
22
22
Children () []error
23
23
}
24
24
25
+ type traceError interface {
26
+ traceString () string
27
+ }
28
+
25
29
type solveError struct {
26
30
lvl errorLevel
27
31
msg string
@@ -54,6 +58,24 @@ func (e *noVersionError) Error() string {
54
58
return buf .String ()
55
59
}
56
60
61
+ func (e * noVersionError ) traceString () string {
62
+ if len (e .fails ) == 0 {
63
+ return fmt .Sprintf ("No versions found" )
64
+ }
65
+
66
+ var buf bytes.Buffer
67
+ fmt .Fprintf (& buf , "No versions of %s met constraints:" , e .pn .LocalName )
68
+ for _ , f := range e .fails {
69
+ if te , ok := f .f .(traceError ); ok {
70
+ fmt .Fprintf (& buf , "\n %s: %s" , f .v , te .traceString ())
71
+ } else {
72
+ fmt .Fprintf (& buf , "\n %s: %s" , f .v , f .f .Error ())
73
+ }
74
+ }
75
+
76
+ return buf .String ()
77
+ }
78
+
57
79
type disjointConstraintFailure struct {
58
80
goal Dependency
59
81
failsib []Dependency
@@ -64,7 +86,7 @@ type disjointConstraintFailure struct {
64
86
func (e * disjointConstraintFailure ) Error () string {
65
87
if len (e .failsib ) == 1 {
66
88
str := "Could not introduce %s at %s, as it has a dependency on %s with constraint %s, which has no overlap with existing constraint %s from %s at %s"
67
- return fmt .Sprintf (str , e .goal .Depender .Ident , e .goal .Depender .Version , e .goal .Dep .Ident .errString (), e .goal .Dep .Constraint .String (), e .failsib [0 ].Dep .Constraint .String (), e .failsib [0 ].Depender .Ident , e .failsib [0 ].Depender .Version )
89
+ return fmt .Sprintf (str , e .goal .Depender .Ident . errString () , e .goal .Depender .Version , e .goal .Dep .Ident .errString (), e .goal .Dep .Constraint .String (), e .failsib [0 ].Dep .Constraint .String (), e .failsib [0 ].Depender .Ident . errString () , e .failsib [0 ].Depender .Version )
68
90
}
69
91
70
92
var buf bytes.Buffer
@@ -74,16 +96,29 @@ func (e *disjointConstraintFailure) Error() string {
74
96
sibs = e .failsib
75
97
76
98
str := "Could not introduce %s at %s, as it has a dependency on %s with constraint %s, which has no overlap with the following existing constraints:\n "
77
- fmt .Fprintf (& buf , str , e .goal .Depender .Ident , e .goal .Depender .Version , e .goal .Dep .Ident .errString (), e .goal .Dep .Constraint .String ())
99
+ fmt .Fprintf (& buf , str , e .goal .Depender .Ident . errString () , e .goal .Depender .Version , e .goal .Dep .Ident .errString (), e .goal .Dep .Constraint .String ())
78
100
} else {
79
101
sibs = e .nofailsib
80
102
81
103
str := "Could not introduce %s at %s, as it has a dependency on %s with constraint %s, which does not overlap with the intersection of existing constraints from other currently selected packages:\n "
82
- fmt .Fprintf (& buf , str , e .goal .Depender .Ident , e .goal .Depender .Version , e .goal .Dep .Ident .errString (), e .goal .Dep .Constraint .String ())
104
+ fmt .Fprintf (& buf , str , e .goal .Depender .Ident . errString () , e .goal .Depender .Version , e .goal .Dep .Ident .errString (), e .goal .Dep .Constraint .String ())
83
105
}
84
106
85
107
for _ , c := range sibs {
86
- fmt .Fprintf (& buf , "\t %s at %s with constraint %s\n " , c .Depender .Ident , c .Depender .Version , c .Dep .Constraint .String ())
108
+ fmt .Fprintf (& buf , "\t %s from %s at %s\n " , c .Dep .Constraint .String (), c .Depender .Ident .errString (), c .Depender .Version )
109
+ }
110
+
111
+ return buf .String ()
112
+ }
113
+
114
+ func (e * disjointConstraintFailure ) traceString () string {
115
+ var buf bytes.Buffer
116
+ fmt .Fprintf (& buf , "constraint %s on %s disjoint with other dependers:\n " , e .goal .Dep .Constraint .String (), e .goal .Dep .Ident .errString ())
117
+ for _ , f := range e .failsib {
118
+ fmt .Fprintf (& buf , "%s from %s at %s (no overlap)\n " , f .Dep .Constraint .String (), f .Depender .Ident .LocalName , f .Depender .Version )
119
+ }
120
+ for _ , f := range e .nofailsib {
121
+ fmt .Fprintf (& buf , "%s from %s at %s (some overlap)\n " , f .Dep .Constraint .String (), f .Depender .Ident .LocalName , f .Depender .Version )
87
122
}
88
123
89
124
return buf .String ()
@@ -102,6 +137,11 @@ func (e *constraintNotAllowedFailure) Error() string {
102
137
return fmt .Sprintf (str , e .goal .Depender .Ident .errString (), e .goal .Depender .Version , e .goal .Dep .Ident .errString (), e .goal .Dep .Constraint , e .v )
103
138
}
104
139
140
+ func (e * constraintNotAllowedFailure ) traceString () string {
141
+ str := "%s at %s depends on %s with %s, but that's already selected at %s"
142
+ return fmt .Sprintf (str , e .goal .Depender .Ident .LocalName , e .goal .Depender .Version , e .goal .Dep .Ident .LocalName , e .goal .Dep .Constraint , e .v )
143
+ }
144
+
105
145
type versionNotAllowedFailure struct {
106
146
goal ProjectAtom
107
147
failparent []Dependency
@@ -111,16 +151,27 @@ type versionNotAllowedFailure struct {
111
151
func (e * versionNotAllowedFailure ) Error () string {
112
152
if len (e .failparent ) == 1 {
113
153
str := "Could not introduce %s at %s, as it is not allowed by constraint %s from project %s."
114
- return fmt .Sprintf (str , e .goal .Ident , e .goal .Version , e .failparent [0 ].Dep .Constraint .String (), e .failparent [0 ].Depender .Ident )
154
+ return fmt .Sprintf (str , e .goal .Ident . errString () , e .goal .Version , e .failparent [0 ].Dep .Constraint .String (), e .failparent [0 ].Depender .Ident . errString () )
115
155
}
116
156
117
157
var buf bytes.Buffer
118
158
119
159
str := "Could not introduce %s at %s, as it is not allowed by constraints from the following projects:\n "
120
- fmt .Fprintf (& buf , str , e .goal .Ident , e .goal .Version )
160
+ fmt .Fprintf (& buf , str , e .goal .Ident .errString (), e .goal .Version )
161
+
162
+ for _ , f := range e .failparent {
163
+ fmt .Fprintf (& buf , "\t %s from %s at %s\n " , f .Dep .Constraint .String (), f .Depender .Ident .errString (), f .Depender .Version )
164
+ }
165
+
166
+ return buf .String ()
167
+ }
121
168
169
+ func (e * versionNotAllowedFailure ) traceString () string {
170
+ var buf bytes.Buffer
171
+
172
+ fmt .Fprintf (& buf , "%s at %s not allowed by constraint %s:\n " , e .goal .Ident .LocalName , e .goal .Version , e .c .String ())
122
173
for _ , f := range e .failparent {
123
- fmt .Fprintf (& buf , "\t %s at %s with constraint %s\n " , f .Depender . Ident , f .Depender .Version , f .Dep . Constraint . String () )
174
+ fmt .Fprintf (& buf , " %s from %s at %s\n " , f .Dep . Constraint . String () , f .Depender .Ident . LocalName , f .Depender . Version )
124
175
}
125
176
126
177
return buf .String ()
@@ -157,3 +208,15 @@ func (e *sourceMismatchFailure) Error() string {
157
208
str := "Could not introduce %s at %s, as it depends on %s from %s, but %s is already marked as coming from %s by %s"
158
209
return fmt .Sprintf (str , e .prob .Ident .errString (), e .prob .Version , e .shared , e .mismatch , e .shared , e .current , strings .Join (cur , ", " ))
159
210
}
211
+
212
+ func (e * sourceMismatchFailure ) traceString () string {
213
+ var buf bytes.Buffer
214
+ fmt .Fprintf (& buf , "disagreement on network addr for %s:\n " , e .shared )
215
+
216
+ fmt .Fprintf (& buf , " %s from %s\n " , e .mismatch , e .prob .Ident .errString ())
217
+ for _ , dep := range e .sel {
218
+ fmt .Fprintf (& buf , " %s from %s\n " , e .current , dep .Depender .Ident .errString ())
219
+ }
220
+
221
+ return buf .String ()
222
+ }
0 commit comments