@@ -4,6 +4,7 @@ use std::fmt;
44
55use super :: { AppError , BoxedAppError , InternalAppErrorStatic } ;
66
7+ use crate :: rate_limiter:: LimitedAction ;
78use chrono:: NaiveDateTime ;
89use http:: { header, StatusCode } ;
910
@@ -74,6 +75,7 @@ pub(super) struct ServerError(pub(super) String);
7475pub ( crate ) struct ServiceUnavailable ( pub ( super ) String ) ;
7576#[ derive( Debug ) ]
7677pub ( crate ) struct TooManyRequests {
78+ pub action : LimitedAction ,
7779 pub retry_after : NaiveDateTime ,
7880}
7981
@@ -131,9 +133,9 @@ impl AppError for TooManyRequests {
131133 let retry_after = self . retry_after . format ( HTTP_DATE_FORMAT ) ;
132134
133135 let detail = format ! (
134- "You have published too many crates in a \
135- short period of time. Please try again after {retry_after} or email \
136- help@crates.io to have your limit increased."
136+ "{}. Please try again after {retry_after} or email \
137+ help@crates.io to have your limit increased." ,
138+ self . action . error_messagge ( )
137139 ) ;
138140 let mut response = json_error ( & detail, StatusCode :: TOO_MANY_REQUESTS ) ;
139141 response. headers_mut ( ) . insert (
0 commit comments