1
+ use std:: borrow:: Cow ;
2
+
1
3
use crate :: {
2
4
db:: PoolError ,
3
5
web:: { page:: WebPage , releases:: Search , AxumErrorPage , ErrorPage } ,
@@ -149,8 +151,8 @@ pub enum AxumNope {
149
151
OwnerNotFound ,
150
152
#[ error( "Requested crate does not have specified version" ) ]
151
153
VersionNotFound ,
152
- #[ error( "Search yielded no results" ) ]
153
- NoResults ,
154
+ // #[error("Search yielded no results")]
155
+ // NoResults,
154
156
#[ error( "Internal server error" ) ]
155
157
InternalServerError ,
156
158
#[ error( "internal error" ) ]
@@ -166,15 +168,15 @@ impl IntoResponse for AxumNope {
166
168
// user tried to navigate to a resource (doc page/file) that doesn't exist
167
169
AxumErrorPage {
168
170
title : "Requested resource does not exist" ,
169
- message : Some ( "no such resource" . into ( ) ) ,
171
+ message : "no such resource" . into ( ) ,
170
172
status : StatusCode :: NOT_FOUND ,
171
173
}
172
174
. into_response ( )
173
175
}
174
176
175
177
AxumNope :: BuildNotFound => AxumErrorPage {
176
178
title : "The requested build does not exist" ,
177
- message : Some ( "no such build" . into ( ) ) ,
179
+ message : "no such build" . into ( ) ,
178
180
status : StatusCode :: NOT_FOUND ,
179
181
}
180
182
. into_response ( ) ,
@@ -184,15 +186,15 @@ impl IntoResponse for AxumNope {
184
186
// TODO: Display the attempted crate and a link to a search for said crate
185
187
AxumErrorPage {
186
188
title : "The requested crate does not exist" ,
187
- message : Some ( "no such crate" . into ( ) ) ,
189
+ message : "no such crate" . into ( ) ,
188
190
status : StatusCode :: NOT_FOUND ,
189
191
}
190
192
. into_response ( )
191
193
}
192
194
193
195
AxumNope :: OwnerNotFound => AxumErrorPage {
194
196
title : "The requested owner does not exist" ,
195
- message : Some ( "no such owner" . into ( ) ) ,
197
+ message : "no such owner" . into ( ) ,
196
198
status : StatusCode :: NOT_FOUND ,
197
199
}
198
200
. into_response ( ) ,
@@ -202,19 +204,19 @@ impl IntoResponse for AxumNope {
202
204
// TODO: Display the attempted crate and version
203
205
AxumErrorPage {
204
206
title : "The requested version does not exist" ,
205
- message : Some ( "no such version for this crate" . into ( ) ) ,
207
+ message : "no such version for this crate" . into ( ) ,
206
208
status : StatusCode :: NOT_FOUND ,
207
209
}
208
210
. into_response ( )
209
211
}
210
- AxumNope :: NoResults => {
211
- todo ! ( "to be implemented when search-handler is migrated to axum" )
212
- }
212
+ // AxumNope::NoResults => {
213
+ // todo!("to be implemented when search-handler is migrated to axum")
214
+ // }
213
215
AxumNope :: InternalServerError => {
214
216
// something went wrong, details should have been logged
215
217
AxumErrorPage {
216
218
title : "Internal server error" ,
217
- message : Some ( "internal server error" . into ( ) ) ,
219
+ message : "internal server error" . into ( ) ,
218
220
status : StatusCode :: INTERNAL_SERVER_ERROR ,
219
221
}
220
222
. into_response ( )
@@ -230,8 +232,8 @@ fn generate_internal_error_page<E: Into<anyhow::Error>>(error: E) -> impl IntoRe
230
232
231
233
let web_error = crate :: web:: AxumErrorPage {
232
234
title : "Internal Server Error" ,
233
- message : :: std :: option :: Option :: Some ( :: std :: borrow :: Cow :: Owned ( error. to_string ( ) ) ) ,
234
- status : :: http :: StatusCode :: INTERNAL_SERVER_ERROR ,
235
+ message : Cow :: Owned ( error. to_string ( ) ) ,
236
+ status : StatusCode :: INTERNAL_SERVER_ERROR ,
235
237
} ;
236
238
237
239
// TODO: check: does the sentry tower layer add the request as context?
0 commit comments