From 4cce71069fbd117eda270dd72df09d175bf2bae2 Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Tue, 12 Dec 2023 16:58:20 -0800 Subject: [PATCH] improve builder `TryInto` failure messages for body parameters (#646) --- Cargo.lock | 1 + progenitor-impl/src/method.rs | 16 +- .../tests/output/buildomat-builder-tagged.out | 18 +- .../tests/output/buildomat-builder.out | 18 +- .../tests/output/keeper-builder-tagged.out | 12 +- .../tests/output/keeper-builder.out | 12 +- .../tests/output/nexus-builder-tagged.out | 227 ++++++++++++------ .../tests/output/nexus-builder.out | 227 ++++++++++++------ .../output/propolis-server-builder-tagged.out | 29 ++- .../tests/output/propolis-server-builder.out | 29 ++- .../output/test_default_params_builder.out | 3 +- progenitor/Cargo.toml | 1 + progenitor/tests/build_nexus.rs | 13 + 13 files changed, 413 insertions(+), 193 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00526ae..fe462f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1391,6 +1391,7 @@ dependencies = [ "schemars", "serde", "serde_json", + "tokio", "uuid", ] diff --git a/progenitor-impl/src/method.rs b/progenitor-impl/src/method.rs index 9b219e0..790d027 100644 --- a/progenitor-impl/src/method.rs +++ b/progenitor-impl/src/method.rs @@ -160,10 +160,8 @@ impl FromStr for BodyContentType { } } -use std::fmt; - -impl fmt::Display for BodyContentType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +impl std::fmt::Display for BodyContentType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(match self { Self::OctetStream => "application/octet-stream", Self::Json => "application/json", @@ -1593,7 +1591,7 @@ impl Generator { unreachable!() } (None, true) => { - let ty_ident = ty.ident(); + let typ = ty.ident(); let err_msg = format!( "conversion to `{}` for {} failed", ty.name(), @@ -1604,7 +1602,7 @@ impl Generator { mut self, value: V, ) -> Self - where V: std::convert::TryInto<#ty_ident>, + where V: std::convert::TryInto<#typ>, { self.#param_name = value.try_into() .map(Some) @@ -1643,7 +1641,7 @@ impl Generator { assert_eq!(param.name, "body"); let typ = ty.ident(); let err_msg = format!( - "conversion to `{}` for {} failed", + "conversion to `{}` for {} failed: {{}}", ty.name(), param.name, ); @@ -1651,10 +1649,12 @@ impl Generator { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto<#typ>, + >::Error: + std::fmt::Display, { self.body = value.try_into() .map(From::from) - .map_err(|_| #err_msg.to_string()); + .map_err(|s| format!(#err_msg, s)); self } diff --git a/progenitor-impl/tests/output/buildomat-builder-tagged.out b/progenitor-impl/tests/output/buildomat-builder-tagged.out index 832b351..e145962 100644 --- a/progenitor-impl/tests/output/buildomat-builder-tagged.out +++ b/progenitor-impl/tests/output/buildomat-builder-tagged.out @@ -2038,11 +2038,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `TaskSubmit` for body failed".to_string()); + .map_err(|s| format!("conversion to `TaskSubmit` for body failed: {}", s)); self } @@ -2292,11 +2293,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); self } @@ -2438,11 +2440,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerBootstrap` for body failed: {}", s)); self } @@ -2545,11 +2548,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerAppendTask` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerAppendTask` for body failed: {}", s)); self } @@ -2688,11 +2692,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerCompleteTask` for body failed: {}", s)); self } @@ -2760,11 +2765,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerAddOutput` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerAddOutput` for body failed: {}", s)); self } diff --git a/progenitor-impl/tests/output/buildomat-builder.out b/progenitor-impl/tests/output/buildomat-builder.out index 077f848..442e959 100644 --- a/progenitor-impl/tests/output/buildomat-builder.out +++ b/progenitor-impl/tests/output/buildomat-builder.out @@ -2038,11 +2038,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `TaskSubmit` for body failed".to_string()); + .map_err(|s| format!("conversion to `TaskSubmit` for body failed: {}", s)); self } @@ -2292,11 +2293,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); self } @@ -2438,11 +2440,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerBootstrap` for body failed: {}", s)); self } @@ -2545,11 +2548,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerAppendTask` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerAppendTask` for body failed: {}", s)); self } @@ -2688,11 +2692,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerCompleteTask` for body failed: {}", s)); self } @@ -2760,11 +2765,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `WorkerAddOutput` for body failed".to_string()); + .map_err(|s| format!("conversion to `WorkerAddOutput` for body failed: {}", s)); self } diff --git a/progenitor-impl/tests/output/keeper-builder-tagged.out b/progenitor-impl/tests/output/keeper-builder-tagged.out index 42065bb..7618efd 100644 --- a/progenitor-impl/tests/output/keeper-builder-tagged.out +++ b/progenitor-impl/tests/output/keeper-builder-tagged.out @@ -1092,11 +1092,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `EnrolBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `EnrolBody` for body failed: {}", s)); self } @@ -1279,11 +1280,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ReportFinishBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `ReportFinishBody` for body failed: {}", s)); self } @@ -1362,11 +1364,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ReportOutputBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `ReportOutputBody` for body failed: {}", s)); self } @@ -1445,11 +1448,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ReportStartBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `ReportStartBody` for body failed: {}", s)); self } diff --git a/progenitor-impl/tests/output/keeper-builder.out b/progenitor-impl/tests/output/keeper-builder.out index bd019a7..436f820 100644 --- a/progenitor-impl/tests/output/keeper-builder.out +++ b/progenitor-impl/tests/output/keeper-builder.out @@ -1092,11 +1092,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `EnrolBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `EnrolBody` for body failed: {}", s)); self } @@ -1279,11 +1280,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ReportFinishBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `ReportFinishBody` for body failed: {}", s)); self } @@ -1362,11 +1364,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ReportOutputBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `ReportOutputBody` for body failed: {}", s)); self } @@ -1445,11 +1448,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ReportStartBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `ReportStartBody` for body failed: {}", s)); self } diff --git a/progenitor-impl/tests/output/nexus-builder-tagged.out b/progenitor-impl/tests/output/nexus-builder-tagged.out index 679c98a..ef1bc50 100644 --- a/progenitor-impl/tests/output/nexus-builder-tagged.out +++ b/progenitor-impl/tests/output/nexus-builder-tagged.out @@ -21699,11 +21699,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DeviceAuthRequest` for body failed".to_string()); + .map_err(|s| format!("conversion to `DeviceAuthRequest` for body failed: {}", s)); self } @@ -21754,11 +21755,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DeviceAuthVerify` for body failed".to_string()); + .map_err(|s| format!("conversion to `DeviceAuthVerify` for body failed: {}", s)); self } @@ -21823,9 +21825,13 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `DeviceAccessTokenRequest` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `DeviceAccessTokenRequest` for body failed: {}", + s + ) }); self } @@ -22034,11 +22040,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SpoofLoginBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `SpoofLoginBody` for body failed: {}", s)); self } @@ -22113,9 +22120,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `UsernamePasswordCredentials` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `UsernamePasswordCredentials` for body failed: {}", + s + ) }); self } @@ -22541,11 +22553,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); self } @@ -22684,11 +22697,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); self } @@ -22900,11 +22914,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); self } @@ -23169,11 +23186,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); self } @@ -23348,11 +23366,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); self } @@ -23722,11 +23741,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); self } @@ -24450,11 +24470,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ImageCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ImageCreate` for body failed: {}", s)); self } @@ -24936,11 +24957,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); self } @@ -25450,11 +25472,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); self } @@ -25570,11 +25593,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); self } @@ -25786,11 +25810,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); self } @@ -26116,11 +26141,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `NetworkInterfaceCreate` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceCreate` for body failed: {}", + s + ) + }); self } @@ -26363,11 +26391,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `NetworkInterfaceUpdate` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceUpdate` for body failed: {}", + s + ) + }); self } @@ -27198,11 +27229,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); self } @@ -27500,11 +27532,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SnapshotCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `SnapshotCreate` for body failed: {}", s)); self } @@ -27985,11 +28018,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcCreate` for body failed: {}", s)); self } @@ -28195,11 +28229,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcUpdate` for body failed: {}", s)); self } @@ -28505,9 +28540,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `VpcFirewallRuleUpdateParams` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `VpcFirewallRuleUpdateParams` for body failed: {}", + s + ) }); self } @@ -28837,11 +28877,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcRouterCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcRouterCreate` for body failed: {}", s)); self } @@ -29078,11 +29119,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcRouterUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcRouterUpdate` for body failed: {}", s)); self } @@ -29546,11 +29588,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `RouterRouteCreateParams` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteCreateParams` for body failed: {}", + s + ) + }); self } @@ -29819,11 +29864,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `RouterRouteUpdateParams` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteUpdateParams` for body failed: {}", + s + ) + }); self } @@ -30280,11 +30328,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcSubnetCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcSubnetCreate` for body failed: {}", s)); self } @@ -30521,11 +30570,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcSubnetUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcSubnetUpdate` for body failed: {}", s)); self } @@ -30984,11 +31034,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); self } @@ -31604,11 +31655,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SshKeyCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `SshKeyCreate` for body failed: {}", s)); self } @@ -32129,11 +32181,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `CertificateCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `CertificateCreate` for body failed: {}", s)); self } @@ -33243,11 +33296,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `GlobalImageCreate` for body failed: {}", s)); self } @@ -33587,11 +33641,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `IpPoolCreate` for body failed: {}", s)); self } @@ -33725,11 +33780,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `IpPoolUpdate` for body failed: {}", s)); self } @@ -34656,11 +34712,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `FleetRolePolicy` for body failed: {}", s)); self } @@ -35098,11 +35155,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SiloCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `SiloCreate` for body failed: {}", s)); self } @@ -35473,11 +35531,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); self } @@ -35734,9 +35793,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `SamlIdentityProviderCreate` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `SamlIdentityProviderCreate` for body failed: {}", + s + ) }); self } @@ -35967,11 +36031,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); self } @@ -37030,11 +37095,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); self } @@ -37530,11 +37596,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); self } @@ -38061,11 +38128,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); self } @@ -38187,11 +38255,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); self } @@ -38313,11 +38382,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); self } @@ -39118,11 +39188,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); self } @@ -39261,11 +39332,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); self } @@ -39477,11 +39549,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); self } @@ -39745,11 +39820,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); self } @@ -39927,11 +40003,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); self } @@ -40201,11 +40278,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); self } @@ -40706,11 +40784,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SystemUpdateStart` for body failed".to_string()); + .map_err(|s| format!("conversion to `SystemUpdateStart` for body failed: {}", s)); self } diff --git a/progenitor-impl/tests/output/nexus-builder.out b/progenitor-impl/tests/output/nexus-builder.out index 9139fac..0e80306 100644 --- a/progenitor-impl/tests/output/nexus-builder.out +++ b/progenitor-impl/tests/output/nexus-builder.out @@ -21493,11 +21493,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DeviceAuthRequest` for body failed".to_string()); + .map_err(|s| format!("conversion to `DeviceAuthRequest` for body failed: {}", s)); self } @@ -21548,11 +21549,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DeviceAuthVerify` for body failed".to_string()); + .map_err(|s| format!("conversion to `DeviceAuthVerify` for body failed: {}", s)); self } @@ -21617,9 +21619,13 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `DeviceAccessTokenRequest` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `DeviceAccessTokenRequest` for body failed: {}", + s + ) }); self } @@ -21828,11 +21834,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SpoofLoginBody` for body failed".to_string()); + .map_err(|s| format!("conversion to `SpoofLoginBody` for body failed: {}", s)); self } @@ -21907,9 +21914,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `UsernamePasswordCredentials` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `UsernamePasswordCredentials` for body failed: {}", + s + ) }); self } @@ -22335,11 +22347,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); self } @@ -22478,11 +22491,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); self } @@ -22694,11 +22708,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); self } @@ -22963,11 +22980,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); self } @@ -23142,11 +23160,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); self } @@ -23516,11 +23535,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); self } @@ -24244,11 +24264,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ImageCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ImageCreate` for body failed: {}", s)); self } @@ -24730,11 +24751,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); self } @@ -25244,11 +25266,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); self } @@ -25364,11 +25387,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); self } @@ -25580,11 +25604,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); self } @@ -25910,11 +25935,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `NetworkInterfaceCreate` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceCreate` for body failed: {}", + s + ) + }); self } @@ -26157,11 +26185,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `NetworkInterfaceUpdate` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceUpdate` for body failed: {}", + s + ) + }); self } @@ -26992,11 +27023,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); self } @@ -27294,11 +27326,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SnapshotCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `SnapshotCreate` for body failed: {}", s)); self } @@ -27779,11 +27812,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcCreate` for body failed: {}", s)); self } @@ -27989,11 +28023,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcUpdate` for body failed: {}", s)); self } @@ -28299,9 +28334,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `VpcFirewallRuleUpdateParams` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `VpcFirewallRuleUpdateParams` for body failed: {}", + s + ) }); self } @@ -28631,11 +28671,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcRouterCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcRouterCreate` for body failed: {}", s)); self } @@ -28872,11 +28913,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcRouterUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcRouterUpdate` for body failed: {}", s)); self } @@ -29340,11 +29382,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `RouterRouteCreateParams` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteCreateParams` for body failed: {}", + s + ) + }); self } @@ -29613,11 +29658,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `RouterRouteUpdateParams` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteUpdateParams` for body failed: {}", + s + ) + }); self } @@ -30074,11 +30122,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcSubnetCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcSubnetCreate` for body failed: {}", s)); self } @@ -30315,11 +30364,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `VpcSubnetUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `VpcSubnetUpdate` for body failed: {}", s)); self } @@ -30778,11 +30828,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); self } @@ -31398,11 +31449,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SshKeyCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `SshKeyCreate` for body failed: {}", s)); self } @@ -31923,11 +31975,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `CertificateCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `CertificateCreate` for body failed: {}", s)); self } @@ -33037,11 +33090,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `GlobalImageCreate` for body failed: {}", s)); self } @@ -33381,11 +33435,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `IpPoolCreate` for body failed: {}", s)); self } @@ -33519,11 +33574,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `IpPoolUpdate` for body failed: {}", s)); self } @@ -34450,11 +34506,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `FleetRolePolicy` for body failed: {}", s)); self } @@ -34892,11 +34949,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SiloCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `SiloCreate` for body failed: {}", s)); self } @@ -35267,11 +35325,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); self } @@ -35528,9 +35587,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `SamlIdentityProviderCreate` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `SamlIdentityProviderCreate` for body failed: {}", + s + ) }); self } @@ -35761,11 +35825,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); self } @@ -36824,11 +36889,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); self } @@ -37324,11 +37390,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); self } @@ -37855,11 +37922,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); self } @@ -37981,11 +38049,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); self } @@ -38107,11 +38176,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); self } @@ -38912,11 +38982,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); self } @@ -39055,11 +39126,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); self } @@ -39271,11 +39343,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); self } @@ -39539,11 +39614,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); self } @@ -39721,11 +39797,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); self } @@ -39995,11 +40072,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); self } @@ -40500,11 +40578,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `SystemUpdateStart` for body failed".to_string()); + .map_err(|s| format!("conversion to `SystemUpdateStart` for body failed: {}", s)); self } diff --git a/progenitor-impl/tests/output/propolis-server-builder-tagged.out b/progenitor-impl/tests/output/propolis-server-builder-tagged.out index 7a8cd29..6776e7f 100644 --- a/progenitor-impl/tests/output/propolis-server-builder-tagged.out +++ b/progenitor-impl/tests/output/propolis-server-builder-tagged.out @@ -2170,11 +2170,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `InstanceEnsureRequest` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceEnsureRequest` for body failed: {}", + s + ) + }); self } @@ -2319,9 +2322,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `InstanceMigrateStatusRequest` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceMigrateStatusRequest` for body failed: {}", + s + ) }); self } @@ -2489,9 +2497,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `InstanceStateMonitorRequest` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceStateMonitorRequest` for body failed: {}", + s + ) }); self } diff --git a/progenitor-impl/tests/output/propolis-server-builder.out b/progenitor-impl/tests/output/propolis-server-builder.out index 3e93141..71c5f11 100644 --- a/progenitor-impl/tests/output/propolis-server-builder.out +++ b/progenitor-impl/tests/output/propolis-server-builder.out @@ -2176,11 +2176,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { - self.body = value - .try_into() - .map(From::from) - .map_err(|_| "conversion to `InstanceEnsureRequest` for body failed".to_string()); + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceEnsureRequest` for body failed: {}", + s + ) + }); self } @@ -2325,9 +2328,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `InstanceMigrateStatusRequest` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceMigrateStatusRequest` for body failed: {}", + s + ) }); self } @@ -2495,9 +2503,14 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: + std::fmt::Display, { - self.body = value.try_into().map(From::from).map_err(|_| { - "conversion to `InstanceStateMonitorRequest` for body failed".to_string() + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceStateMonitorRequest` for body failed: {}", + s + ) }); self } diff --git a/progenitor-impl/tests/output/test_default_params_builder.out b/progenitor-impl/tests/output/test_default_params_builder.out index 59aa94e..491259e 100644 --- a/progenitor-impl/tests/output/test_default_params_builder.out +++ b/progenitor-impl/tests/output/test_default_params_builder.out @@ -324,11 +324,12 @@ pub mod builder { pub fn body(mut self, value: V) -> Self where V: std::convert::TryInto, + >::Error: std::fmt::Display, { self.body = value .try_into() .map(From::from) - .map_err(|_| "conversion to `BodyWithDefaults` for body failed".to_string()); + .map_err(|s| format!("conversion to `BodyWithDefaults` for body failed: {}", s)); self } diff --git a/progenitor/Cargo.toml b/progenitor/Cargo.toml index 5b9b1f4..579dbc2 100644 --- a/progenitor/Cargo.toml +++ b/progenitor/Cargo.toml @@ -26,3 +26,4 @@ reqwest = { version = "0.11.22", features = ["json", "stream"] } schemars = { version = "0.8.12", features = ["uuid1"] } serde = { version = "1.0", features = ["derive"] } uuid = { version = "1.6", features = ["serde", "v4"] } +tokio = "*" \ No newline at end of file diff --git a/progenitor/tests/build_nexus.rs b/progenitor/tests/build_nexus.rs index a9fd73a..0276a61 100644 --- a/progenitor/tests/build_nexus.rs +++ b/progenitor/tests/build_nexus.rs @@ -85,6 +85,8 @@ mod builder_tagged { use nexus_client::prelude::*; + use self::nexus_client::types; + async fn _ignore() { let client = Client::new(""); let stream = client @@ -103,4 +105,15 @@ mod builder_tagged { .send() .await; } + + #[tokio::test] + #[should_panic = "called `Result::unwrap()` on an `Err` value: Invalid Request: conversion to `SiloCreate` for body failed: no value supplied for description"] + async fn test_decent_error_from_body_builder() { + let _ = Client::new("") + .silo_create() + .body(types::SiloCreate::builder()) + .send() + .await + .unwrap(); + } }