File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
exercises/tiered_pricing/solutions/isaac1024_baby-steps/src Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -12,11 +12,20 @@ struct Subscriptions {
1212 pricing : u32 ,
1313}
1414
15+ #[ derive( Serialize , Deserialize ) ]
16+ struct BadRequestMessage {
17+ error_message : String ,
18+ }
19+
1520pub async fn tiered_pricing ( pricing : web:: Query < Pricing > ) -> impl Responder {
16- let total_price = get_total_subscription_price ( pricing. subscriptions ) . unwrap ( ) ;
17- HttpResponse :: Ok ( ) . json ( Subscriptions {
18- pricing : total_price,
19- } )
21+ match get_total_subscription_price ( pricing. subscriptions ) {
22+ Ok ( total_price) => HttpResponse :: Ok ( ) . json ( Subscriptions {
23+ pricing : total_price,
24+ } ) ,
25+ Err ( error) => HttpResponse :: BadRequest ( ) . json ( BadRequestMessage {
26+ error_message : error. to_string ( ) ,
27+ } ) ,
28+ }
2029}
2130
2231type SubscriptionResult < T > = Result < T , NumberSubscriptionsError > ;
You can’t perform that action at this time.
0 commit comments