1- use std:: io :: Result ;
1+ use std:: result :: Result ;
22
33pub struct CallArgs {
44 pub privileges : Privilege ,
@@ -7,24 +7,18 @@ pub struct CallArgs {
77
88impl CallArgs {
99 #[ allow( clippy:: single_match) ]
10- pub async fn validate ( & self ) -> Result < ( ) > {
10+ pub async fn validate ( & self ) -> Result < ( ) , Box < dyn std :: error :: Error > > {
1111 match self . privileges {
1212 Privilege :: Normal => match & self . command {
1313 Command :: Render ( args) => {
1414 match args. backend {
1515 #[ cfg( feature = "backend+ui" ) ]
16- Backend :: UI => return Err ( std:: io:: Error :: new (
17- std:: io:: ErrorKind :: Other ,
18- "can not use backend+ui without experimental features being activated" ,
19- ) ) ,
16+ Backend :: UI => return Err ( Box :: new ( crate :: error:: NeedExperimentalFlag :: default ( ) ) ) ,
2017 #[ cfg( feature = "backend+cli" ) ]
2118 Backend :: CLI => { }
2219 } ;
2320 if args. value_overrides . len ( ) > 0 {
24- return Err ( std:: io:: Error :: new (
25- std:: io:: ErrorKind :: Other ,
26- "value overrides is an experimental feature and needs the respective flag to be active" ,
27- ) ) ;
21+ return Err ( Box :: new ( crate :: error:: NeedExperimentalFlag :: default ( ) ) ) ;
2822 }
2923 #[ allow( unreachable_code) ]
3024 Ok ( ( ) )
@@ -70,7 +64,7 @@ pub enum Backend {
7064pub struct ClapArgumentLoader { }
7165
7266impl ClapArgumentLoader {
73- pub async fn load_from_cli ( ) -> std:: io :: Result < CallArgs > {
67+ pub async fn load_from_cli ( ) -> std:: result :: Result < CallArgs , Box < dyn std :: error :: Error > > {
7468 let mut backend_values = Vec :: new ( ) ;
7569 if cfg ! ( feature = "backend+cli" ) {
7670 backend_values. push ( "cli" ) ;
@@ -159,10 +153,7 @@ impl ClapArgumentLoader {
159153 let config_param = x. value_of ( "config" ) . unwrap ( ) ;
160154 std:: fs:: read_to_string ( config_param. to_owned ( ) ) ?
161155 } else {
162- return Err ( std:: io:: Error :: new (
163- std:: io:: ErrorKind :: Other ,
164- "configuration not specified" ,
165- ) ) ;
156+ return Err ( Box :: new ( crate :: error:: Failed :: new ( "configuration unspecified" ) ) ) ;
166157 } ;
167158
168159 let template = if x. is_present ( "template" ) {
@@ -197,10 +188,7 @@ impl ClapArgumentLoader {
197188 #[ cfg( feature = "backend+ui" ) ]
198189 "ui" => Backend :: UI ,
199190 _ => {
200- return Err ( std:: io:: Error :: new (
201- std:: io:: ErrorKind :: Other ,
202- "unknown backend configuration" ,
203- ) )
191+ return Err ( Box :: new ( crate :: error:: Failed :: new ( "no backend specified" ) ) )
204192 }
205193 } ,
206194 #[ cfg( feature = "backend+cli" ) ]
@@ -221,10 +209,7 @@ impl ClapArgumentLoader {
221209 } ) ,
222210 } )
223211 }
224- None => Err ( std:: io:: Error :: new (
225- std:: io:: ErrorKind :: Other ,
226- "could not resolve subcommand" ,
227- ) ) ,
212+ None => Err ( Box :: new ( crate :: error:: UnknownCommand :: default ( ) ) ) ,
228213 }
229214 }
230215}
0 commit comments