@@ -60,25 +60,25 @@ pub enum Error {
60
60
#[ error( "{0}: {1}" ) ]
61
61
Io ( String , io:: Error ) ,
62
62
63
- #[ error( "Io Error :" ) ]
63
+ #[ error( "io error :" ) ]
64
64
StdIo ( #[ from] io:: Error ) ,
65
65
66
66
#[ error( "{0}: {1}" ) ]
67
67
Json ( String , JsonError ) ,
68
68
69
- #[ error( "Failed to parse toml file: {0}" ) ]
69
+ #[ error( "failed to parse toml file: {0}" ) ]
70
70
TomlParse ( #[ from] TomlError ) ,
71
71
72
- #[ error( "Failed to convert bytes to string: {0}" ) ]
72
+ #[ error( "failed to convert bytes to string: {0}" ) ]
73
73
ConvertBytesToString ( #[ from] str:: Utf8Error ) ,
74
74
75
- #[ error( "Error preparing fetch repository: {0}" ) ]
75
+ #[ error( "preparing fetch repository: {0}" ) ]
76
76
PrepareFetch ( Box < clone:: Error > ) ,
77
77
78
- #[ error( "Failed to fetch repository: {0}" ) ]
78
+ #[ error( "failed to fetch repository: {0}" ) ]
79
79
Fetch ( Box < clone:: fetch:: Error > ) ,
80
80
81
- #[ error( "Failed to checkout main worktree: {0}" ) ]
81
+ #[ error( "failed to checkout main worktree: {0}" ) ]
82
82
Checkout ( #[ from] clone:: checkout:: main_worktree:: Error ) ,
83
83
}
84
84
@@ -119,12 +119,8 @@ impl Runner {
119
119
120
120
if !self . args . frontend_template . is_empty ( ) {
121
121
// create a temp dir for the template repo
122
- let fe_template_dir = tempfile:: tempdir ( ) . map_err ( |e| {
123
- Error :: Io (
124
- "Error creating temp dir for frontend template" . to_string ( ) ,
125
- e,
126
- )
127
- } ) ?;
122
+ let fe_template_dir = tempfile:: tempdir ( )
123
+ . map_err ( |e| Error :: Io ( "creating temp dir for frontend template" . to_string ( ) , e) ) ?;
128
124
129
125
// clone the template repo into the temp dir
130
126
Self :: clone_repo ( & self . args . frontend_template , fe_template_dir. path ( ) ) ?;
@@ -136,12 +132,8 @@ impl Runner {
136
132
// if there are --with-example flags, include the example contracts
137
133
if self . include_example_contracts ( ) {
138
134
// create an examples temp dir
139
- let examples_dir = tempfile:: tempdir ( ) . map_err ( |e| {
140
- Error :: Io (
141
- "Error creating temp dir for soroban-examples" . to_string ( ) ,
142
- e,
143
- )
144
- } ) ?;
135
+ let examples_dir = tempfile:: tempdir ( )
136
+ . map_err ( |e| Error :: Io ( "creating temp dir for soroban-examples" . to_string ( ) , e) ) ?;
145
137
146
138
// clone the soroban-examples repo into the temp dir
147
139
Self :: clone_repo ( SOROBAN_EXAMPLES_URL , examples_dir. path ( ) ) ?;
@@ -206,11 +198,11 @@ impl Runner {
206
198
"target" ,
207
199
"Cargo.lock" ,
208
200
] ;
209
- for entry in read_dir ( from )
210
- . map_err ( |e| Error :: Io ( format ! ( "Error reading directory: {from:?}" ) , e) ) ?
201
+ for entry in
202
+ read_dir ( from ) . map_err ( |e| Error :: Io ( format ! ( "reading directory: {from:?}" ) , e) ) ?
211
203
{
212
- let entry = entry
213
- . map_err ( |e| Error :: Io ( format ! ( "Error reading entry in directory {from:?}" , ) , e) ) ?;
204
+ let entry =
205
+ entry . map_err ( |e| Error :: Io ( format ! ( "reading entry in directory {from:?}" , ) , e) ) ?;
214
206
let path = entry. path ( ) ;
215
207
let entry_name = entry. file_name ( ) . to_string_lossy ( ) . to_string ( ) ;
216
208
let new_path = to. join ( & entry_name) ;
@@ -248,7 +240,7 @@ impl Runner {
248
240
copy ( & path, & new_path) . map_err ( |e| {
249
241
Error :: Io (
250
242
format ! (
251
- "Error copying from {:?} to {:?}" ,
243
+ "copying from {:?} to {:?}" ,
252
244
path. to_string_lossy( ) ,
253
245
new_path
254
246
) ,
@@ -365,7 +357,7 @@ impl Runner {
365
357
name. to_owned ( )
366
358
} else {
367
359
let current_dir = env:: current_dir ( )
368
- . map_err ( |e| Error :: Io ( "Error getting current dir from env" . to_string ( ) , e) ) ?;
360
+ . map_err ( |e| Error :: Io ( "getting current dir from env" . to_string ( ) , e) ) ?;
369
361
let file_name = current_dir
370
362
. file_name ( )
371
363
. unwrap_or ( OsStr :: new ( "soroban-astro-template" ) )
@@ -386,20 +378,13 @@ impl Runner {
386
378
let file_contents = Self :: read_to_string ( & file_path) ?;
387
379
388
380
let mut doc: JsonValue = from_str ( & file_contents) . map_err ( |e| {
389
- Error :: Json (
390
- format ! ( "Error parsing {file_name} file in: {project_path:?}" ) ,
391
- e,
392
- )
381
+ Error :: Json ( format ! ( "parsing {file_name} file in: {project_path:?}" ) , e)
393
382
} ) ?;
394
383
395
384
doc[ "name" ] = json ! ( package_name. to_string_lossy( ) ) ;
396
385
397
- let formatted_json = to_string_pretty ( & doc) . map_err ( |e| {
398
- Error :: Json (
399
- "Error calling to_string_pretty for package.json" . to_string ( ) ,
400
- e,
401
- )
402
- } ) ?;
386
+ let formatted_json = to_string_pretty ( & doc)
387
+ . map_err ( |e| Error :: Json ( "calling to_string_pretty for package.json" . to_string ( ) , e) ) ?;
403
388
404
389
Self :: write ( & file_path, & formatted_json) ?;
405
390
@@ -442,16 +427,15 @@ impl Runner {
442
427
}
443
428
444
429
fn create_dir_all ( path : & Path ) -> Result < ( ) , Error > {
445
- create_dir_all ( path)
446
- . map_err ( |e| Error :: Io ( format ! ( "Error creating directory: {path:?}" ) , e) )
430
+ create_dir_all ( path) . map_err ( |e| Error :: Io ( format ! ( "creating directory: {path:?}" ) , e) )
447
431
}
448
432
449
433
fn write ( path : & Path , contents : & str ) -> Result < ( ) , Error > {
450
- write ( path, contents) . map_err ( |e| Error :: Io ( format ! ( "Error writing file: {path:?}" ) , e) )
434
+ write ( path, contents) . map_err ( |e| Error :: Io ( format ! ( "writing file: {path:?}" ) , e) )
451
435
}
452
436
453
437
fn read_to_string ( path : & Path ) -> Result < String , Error > {
454
- read_to_string ( path) . map_err ( |e| Error :: Io ( format ! ( "Error reading file: {path:?}" ) , e) )
438
+ read_to_string ( path) . map_err ( |e| Error :: Io ( format ! ( "reading file: {path:?}" ) , e) )
455
439
}
456
440
}
457
441
0 commit comments