File tree Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ use crate::{
1818 } ,
1919 lib_context:: LibContext ,
2020 ops:: interface:: FlowInstanceContext ,
21- py:: IntoPyResult ,
21+ py:: { AnyhowIntoPyResult , IntoPyResult } ,
2222} ;
2323use crate :: { lib_context:: FlowContext , py} ;
2424
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use futures::future::try_join_all;
55
66use crate :: base:: value:: EstimatedByteSize ;
77use crate :: builder:: { AnalyzedTransientFlow , plan:: * } ;
8- use crate :: py:: IntoPyResult ;
8+ use crate :: py:: AnyhowIntoPyResult ;
99use crate :: {
1010 base:: { schema, value} ,
1111 utils:: immutable:: RefList ,
@@ -73,6 +73,7 @@ impl ScopeValueBuilder {
7373 . zip ( & mut builder. fields )
7474 {
7575 r. set ( augmented_value ( v, & t. value_type . typ ) ?)
76+ . map_err ( |_| anyhow ! ( "Value of field `{}` is already set" , t. name) )
7677 . into_py_result ( ) ?;
7778 }
7879 Ok ( builder)
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ use pythonize::{depythonize, pythonize};
1212use serde:: de:: DeserializeOwned ;
1313use std:: ops:: Deref ;
1414
15- use super :: IntoPyResult ;
15+ use super :: { AnyhowIntoPyResult , IntoPyResult } ;
1616
1717#[ derive( Debug ) ]
1818pub struct Pythonized < T > ( pub T ) ;
Original file line number Diff line number Diff line change @@ -72,7 +72,20 @@ pub trait IntoPyResult<T> {
7272 fn into_py_result ( self ) -> PyResult < T > ;
7373}
7474
75- impl < T , E : std:: fmt:: Debug > IntoPyResult < T > for Result < T , E > {
75+ impl < T , E : std:: error:: Error > IntoPyResult < T > for Result < T , E > {
76+ fn into_py_result ( self ) -> PyResult < T > {
77+ match self {
78+ Ok ( value) => Ok ( value) ,
79+ Err ( err) => Err ( PyException :: new_err ( format ! ( "{err:?}" ) ) ) ,
80+ }
81+ }
82+ }
83+
84+ pub trait AnyhowIntoPyResult < T > {
85+ fn into_py_result ( self ) -> PyResult < T > ;
86+ }
87+
88+ impl < T > AnyhowIntoPyResult < T > for anyhow:: Result < T > {
7689 fn into_py_result ( self ) -> PyResult < T > {
7790 match self {
7891 Ok ( value) => Ok ( value) ,
You can’t perform that action at this time.
0 commit comments