11use catalyst_toolbox:: ideascale:: {
2- build_challenges, build_fund, build_proposals, fetch_all, CustomFieldTags ,
3- Error as IdeascaleError , Scores , Sponsors ,
2+ build_challenges, build_fund, build_proposals, fetch_all, CustomFieldTags , Scores , Sponsors ,
43} ;
4+ use color_eyre:: Report ;
55use jcli_lib:: utils:: io as io_utils;
66use jormungandr_lib:: interfaces:: VotePrivacy ;
77use std:: collections:: HashSet ;
@@ -12,21 +12,6 @@ use serde::de::DeserializeOwned;
1212use serde:: Serialize ;
1313use std:: path:: { Path , PathBuf } ;
1414
15- #[ derive( thiserror:: Error , Debug ) ]
16- pub enum Error {
17- #[ error( transparent) ]
18- Ideascale ( #[ from] IdeascaleError ) ,
19-
20- #[ error( transparent) ]
21- Io ( #[ from] std:: io:: Error ) ,
22-
23- #[ error( transparent) ]
24- Csv ( #[ from] csv:: Error ) ,
25-
26- #[ error( transparent) ]
27- Serde ( #[ from] serde_json:: Error ) ,
28- }
29-
3015#[ derive( Debug , StructOpt ) ]
3116pub enum Ideascale {
3217 Import ( Import ) ,
@@ -89,15 +74,15 @@ pub struct Import {
8974}
9075
9176impl Ideascale {
92- pub fn exec ( & self ) -> Result < ( ) , Error > {
77+ pub fn exec ( & self ) -> Result < ( ) , Report > {
9378 match self {
9479 Ideascale :: Import ( import) => import. exec ( ) ,
9580 }
9681 }
9782}
9883
9984impl Import {
100- fn exec ( & self ) -> Result < ( ) , Error > {
85+ fn exec ( & self ) -> Result < ( ) , Report > {
10186 let Import {
10287 fund,
10388 fund_goal,
@@ -182,21 +167,22 @@ impl Import {
182167 }
183168}
184169
185- fn dump_content_to_file ( content : impl Serialize , file_path : & Path ) -> Result < ( ) , Error > {
170+ fn dump_content_to_file ( content : impl Serialize , file_path : & Path ) -> Result < ( ) , Report > {
186171 let writer = jcli_lib:: utils:: io:: open_file_write ( & Some ( file_path) ) ?;
187- serde_json:: to_writer_pretty ( writer, & content) . map_err ( Error :: Serde )
172+ serde_json:: to_writer_pretty ( writer, & content) ?;
173+ Ok ( ( ) )
188174}
189175
190- fn read_json_from_file < T : DeserializeOwned > ( file_path : & Path ) -> Result < T , Error > {
176+ fn read_json_from_file < T : DeserializeOwned > ( file_path : & Path ) -> Result < T , Report > {
191177 let reader = io_utils:: open_file_read ( & Some ( file_path) ) ?;
192- serde_json:: from_reader ( reader) . map_err ( Error :: Serde )
178+ Ok ( serde_json:: from_reader ( reader) ? )
193179}
194180
195181fn parse_from_csv ( s : & str ) -> Filters {
196182 s. split ( ';' ) . map ( |x| x. to_string ( ) ) . collect ( )
197183}
198184
199- fn read_scores_file ( path : & Option < PathBuf > ) -> Result < Scores , Error > {
185+ fn read_scores_file ( path : & Option < PathBuf > ) -> Result < Scores , Report > {
200186 let mut scores = Scores :: new ( ) ;
201187 if let Some ( path) = path {
202188 let mut reader = csv:: Reader :: from_path ( path) ?;
@@ -218,7 +204,7 @@ fn read_scores_file(path: &Option<PathBuf>) -> Result<Scores, Error> {
218204 Ok ( scores)
219205}
220206
221- fn read_sponsors_file ( path : & Option < PathBuf > ) -> Result < Sponsors , Error > {
207+ fn read_sponsors_file ( path : & Option < PathBuf > ) -> Result < Sponsors , Report > {
222208 let mut sponsors = Sponsors :: new ( ) ;
223209
224210 if let Some ( path) = path {
0 commit comments