@@ -185,12 +185,14 @@ fn check_exercises_unsolved(
185185 return None ;
186186 }
187187
188- Some ( (
189- exercise_info. name . as_str ( ) ,
190- thread:: spawn ( || exercise_info. run_exercise ( None , cmd_runner) ) ,
191- ) )
188+ Some (
189+ thread:: Builder :: new ( )
190+ . spawn ( || exercise_info. run_exercise ( None , cmd_runner) )
191+ . map ( |handle| ( exercise_info. name . as_str ( ) , handle) ) ,
192+ )
192193 } )
193- . collect :: < Vec < _ > > ( ) ;
194+ . collect :: < Result < Vec < _ > , _ > > ( )
195+ . context ( "Failed to spawn a thread to check if an exercise is already solved" ) ?;
194196
195197 let n_handles = handles. len ( ) ;
196198 write ! ( stdout, "Progress: 0/{n_handles}" ) ?;
@@ -226,7 +228,9 @@ fn check_exercises(info_file: &'static InfoFile, cmd_runner: &'static CmdRunner)
226228 Ordering :: Equal => ( ) ,
227229 }
228230
229- let handle = thread:: spawn ( move || check_exercises_unsolved ( info_file, cmd_runner) ) ;
231+ let handle = thread:: Builder :: new ( )
232+ . spawn ( move || check_exercises_unsolved ( info_file, cmd_runner) )
233+ . context ( "Failed to spawn a thread to check if any exercise is already solved" ) ?;
230234
231235 let info_file_paths = check_info_file_exercises ( info_file) ?;
232236 check_unexpected_files ( "exercises" , & info_file_paths) ?;
@@ -253,7 +257,7 @@ fn check_solutions(
253257 . exercises
254258 . iter ( )
255259 . map ( |exercise_info| {
256- thread:: spawn ( move || {
260+ thread:: Builder :: new ( ) . spawn ( move || {
257261 let sol_path = exercise_info. sol_path ( ) ;
258262 if !Path :: new ( & sol_path) . exists ( ) {
259263 if require_solutions {
@@ -274,7 +278,8 @@ fn check_solutions(
274278 }
275279 } )
276280 } )
277- . collect :: < Vec < _ > > ( ) ;
281+ . collect :: < Result < Vec < _ > , _ > > ( )
282+ . context ( "Failed to spawn a thread to check a solution" ) ?;
278283
279284 let mut sol_paths = hash_set_with_capacity ( info_file. exercises . len ( ) ) ;
280285 let mut fmt_cmd = Command :: new ( "rustfmt" ) ;
@@ -322,7 +327,11 @@ fn check_solutions(
322327 }
323328 stdout. write_all ( b"\n " ) ?;
324329
325- let handle = thread:: spawn ( move || check_unexpected_files ( "solutions" , & sol_paths) ) ;
330+ let handle = thread:: Builder :: new ( )
331+ . spawn ( move || check_unexpected_files ( "solutions" , & sol_paths) )
332+ . context (
333+ "Failed to spawn a thread to check for unexpected files in the solutions directory" ,
334+ ) ?;
326335
327336 if !fmt_cmd
328337 . status ( )
0 commit comments