@@ -9,6 +9,8 @@ use uv_normalize::PackageName;
9
9
10
10
use crate :: commands:: pip;
11
11
12
+ type Error = Box < dyn std:: error:: Error + Send + Sync > ;
13
+
12
14
/// Static map of common package name typos or misconfigurations to their correct package names.
13
15
static SUGGESTIONS : LazyLock < FxHashMap < PackageName , PackageName > > = LazyLock :: new ( || {
14
16
let suggestions: Vec < ( String , String ) > =
@@ -74,37 +76,37 @@ impl OperationDiagnostic {
74
76
dist,
75
77
err,
76
78
) ) => {
77
- download_and_build ( dist, err) ;
79
+ download_and_build ( dist, Box :: new ( err) ) ;
78
80
None
79
81
}
80
82
pip:: operations:: Error :: Resolve ( uv_resolver:: ResolveError :: Build ( dist, err) ) => {
81
- build ( dist, err) ;
83
+ build ( dist, Box :: new ( err) ) ;
82
84
None
83
85
}
84
86
pip:: operations:: Error :: Requirements ( uv_requirements:: Error :: DownloadAndBuild (
85
87
dist,
86
88
err,
87
89
) ) => {
88
- download_and_build ( dist, err) ;
90
+ download_and_build ( dist, Box :: new ( err) ) ;
89
91
None
90
92
}
91
93
pip:: operations:: Error :: Requirements ( uv_requirements:: Error :: Build ( dist, err) ) => {
92
- build ( dist, err) ;
94
+ build ( dist, Box :: new ( err) ) ;
93
95
None
94
96
}
95
97
pip:: operations:: Error :: Prepare ( uv_installer:: PrepareError :: Build ( dist, err) ) => {
96
- build ( dist, err) ;
98
+ build ( dist, Box :: new ( err) ) ;
97
99
None
98
100
}
99
101
pip:: operations:: Error :: Prepare ( uv_installer:: PrepareError :: DownloadAndBuild (
100
102
dist,
101
103
err,
102
104
) ) => {
103
- download_and_build ( dist, err) ;
105
+ download_and_build ( dist, Box :: new ( err) ) ;
104
106
None
105
107
}
106
108
pip:: operations:: Error :: Prepare ( uv_installer:: PrepareError :: Download ( dist, err) ) => {
107
- download ( dist, err) ;
109
+ download ( dist, Box :: new ( err) ) ;
108
110
None
109
111
}
110
112
pip:: operations:: Error :: Requirements ( err) => {
@@ -123,19 +125,19 @@ impl OperationDiagnostic {
123
125
}
124
126
125
127
/// Render a remote source distribution build failure with a help message.
126
- pub ( crate ) fn download_and_build ( sdist : Box < SourceDist > , cause : uv_distribution :: Error ) {
128
+ pub ( crate ) fn download_and_build ( sdist : Box < SourceDist > , cause : Error ) {
127
129
#[ derive( Debug , miette:: Diagnostic , thiserror:: Error ) ]
128
130
#[ error( "Failed to download and build `{sdist}`" ) ]
129
131
#[ diagnostic( ) ]
130
- struct Error {
132
+ struct Diagnostic {
131
133
sdist : Box < SourceDist > ,
132
134
#[ source]
133
- cause : uv_distribution :: Error ,
135
+ cause : Error ,
134
136
#[ help]
135
137
help : Option < String > ,
136
138
}
137
139
138
- let report = miette:: Report :: new ( Error {
140
+ let report = miette:: Report :: new ( Diagnostic {
139
141
help : SUGGESTIONS . get ( sdist. name ( ) ) . map ( |suggestion| {
140
142
format ! (
141
143
"`{}` is often confused for `{}` Did you mean to install `{}` instead?" ,
@@ -151,19 +153,19 @@ pub(crate) fn download_and_build(sdist: Box<SourceDist>, cause: uv_distribution:
151
153
}
152
154
153
155
/// Render a remote binary distribution download failure with a help message.
154
- pub ( crate ) fn download ( sdist : Box < BuiltDist > , cause : uv_distribution :: Error ) {
156
+ pub ( crate ) fn download ( sdist : Box < BuiltDist > , cause : Error ) {
155
157
#[ derive( Debug , miette:: Diagnostic , thiserror:: Error ) ]
156
158
#[ error( "Failed to download `{sdist}`" ) ]
157
159
#[ diagnostic( ) ]
158
- struct Error {
160
+ struct Diagnostic {
159
161
sdist : Box < BuiltDist > ,
160
162
#[ source]
161
- cause : uv_distribution :: Error ,
163
+ cause : Error ,
162
164
#[ help]
163
165
help : Option < String > ,
164
166
}
165
167
166
- let report = miette:: Report :: new ( Error {
168
+ let report = miette:: Report :: new ( Diagnostic {
167
169
help : SUGGESTIONS . get ( sdist. name ( ) ) . map ( |suggestion| {
168
170
format ! (
169
171
"`{}` is often confused for `{}` Did you mean to install `{}` instead?" ,
@@ -179,19 +181,19 @@ pub(crate) fn download(sdist: Box<BuiltDist>, cause: uv_distribution::Error) {
179
181
}
180
182
181
183
/// Render a local source distribution build failure with a help message.
182
- pub ( crate ) fn build ( sdist : Box < SourceDist > , cause : uv_distribution :: Error ) {
184
+ pub ( crate ) fn build ( sdist : Box < SourceDist > , cause : Error ) {
183
185
#[ derive( Debug , miette:: Diagnostic , thiserror:: Error ) ]
184
186
#[ error( "Failed to build `{sdist}`" ) ]
185
187
#[ diagnostic( ) ]
186
- struct Error {
188
+ struct Diagnostic {
187
189
sdist : Box < SourceDist > ,
188
190
#[ source]
189
- cause : uv_distribution :: Error ,
191
+ cause : Error ,
190
192
#[ help]
191
193
help : Option < String > ,
192
194
}
193
195
194
- let report = miette:: Report :: new ( Error {
196
+ let report = miette:: Report :: new ( Diagnostic {
195
197
help : SUGGESTIONS . get ( sdist. name ( ) ) . map ( |suggestion| {
196
198
format ! (
197
199
"`{}` is often confused for `{}` Did you mean to install `{}` instead?" ,
0 commit comments