@@ -297,9 +297,7 @@ fn download_model_solution(mut cx: FunctionContext) -> JsResult<JsValue> {
297
297
) ;
298
298
299
299
let res = with_client ( client_name, client_version, |client| {
300
- Ok ( client
301
- . download_model_solution ( exercise_id, & target)
302
- . map_err ( Box :: new) ?)
300
+ Ok ( client. download_model_solution ( exercise_id, & target) ?)
303
301
} ) ;
304
302
convert_res ( & mut cx, res)
305
303
}
@@ -393,7 +391,7 @@ fn get_course_details(mut cx: FunctionContext) -> JsResult<JsValue> {
393
391
) ;
394
392
395
393
let res = with_client ( client_name, client_version, |client| {
396
- Ok ( client. get_course_details ( course_id) . map_err ( Box :: new ) ?)
394
+ Ok ( client. get_course_details ( course_id) ?)
397
395
} ) ;
398
396
convert_res ( & mut cx, res)
399
397
}
@@ -407,7 +405,7 @@ fn get_course_exercises(mut cx: FunctionContext) -> JsResult<JsValue> {
407
405
) ;
408
406
409
407
let res = with_client ( client_name, client_version, |client| {
410
- Ok ( client. get_course_exercises ( course_id) . map_err ( Box :: new ) ?)
408
+ Ok ( client. get_course_exercises ( course_id) ?)
411
409
} ) ;
412
410
convert_res ( & mut cx, res)
413
411
}
@@ -421,7 +419,7 @@ fn get_course_settings(mut cx: FunctionContext) -> JsResult<JsValue> {
421
419
) ;
422
420
423
421
let res = with_client ( client_name, client_version, |client| {
424
- Ok ( client. get_course ( course_id) . map_err ( Box :: new ) ?)
422
+ Ok ( client. get_course ( course_id) ?)
425
423
} ) ;
426
424
convert_res ( & mut cx, res)
427
425
}
@@ -435,7 +433,7 @@ fn get_courses(mut cx: FunctionContext) -> JsResult<JsValue> {
435
433
) ;
436
434
437
435
let res = with_client ( client_name, client_version, |client| {
438
- Ok ( client. list_courses ( & organization) . map_err ( Box :: new ) ?)
436
+ Ok ( client. list_courses ( & organization) ?)
439
437
} ) ;
440
438
convert_res ( & mut cx, res)
441
439
}
@@ -449,7 +447,7 @@ fn get_exercise_details(mut cx: FunctionContext) -> JsResult<JsValue> {
449
447
) ;
450
448
451
449
let res = with_client ( client_name, client_version, |client| {
452
- Ok ( client. get_exercise_details ( exercise_id) . map_err ( Box :: new ) ?)
450
+ Ok ( client. get_exercise_details ( exercise_id) ?)
453
451
} ) ;
454
452
convert_res ( & mut cx, res)
455
453
}
@@ -463,9 +461,7 @@ fn get_exercise_submissions(mut cx: FunctionContext) -> JsResult<JsValue> {
463
461
) ;
464
462
465
463
let res = with_client ( client_name, client_version, |client| {
466
- Ok ( client
467
- . get_exercise_submissions_for_current_user ( exercise_id)
468
- . map_err ( Box :: new) ?)
464
+ Ok ( client. get_exercise_submissions_for_current_user ( exercise_id) ?)
469
465
} ) ;
470
466
convert_res ( & mut cx, res)
471
467
}
@@ -481,9 +477,7 @@ fn get_exercise_updates(mut cx: FunctionContext) -> JsResult<JsValue> {
481
477
482
478
let map = exercise. into_iter ( ) . collect ( ) ;
483
479
let res = with_client ( client_name, client_version, |client| {
484
- Ok ( client
485
- . get_exercise_updates ( course_id, map)
486
- . map_err ( Box :: new) ?)
480
+ Ok ( client. get_exercise_updates ( course_id, map) ?)
487
481
} ) ;
488
482
convert_res ( & mut cx, res)
489
483
}
@@ -497,7 +491,7 @@ fn get_organization(mut cx: FunctionContext) -> JsResult<JsValue> {
497
491
) ;
498
492
499
493
let res = with_client ( client_name, client_version, |client| {
500
- Ok ( client. get_organization ( & organization) . map_err ( Box :: new ) ?)
494
+ Ok ( client. get_organization ( & organization) ?)
501
495
} ) ;
502
496
convert_res ( & mut cx, res)
503
497
}
@@ -506,7 +500,7 @@ fn get_organizations(mut cx: FunctionContext) -> JsResult<JsValue> {
506
500
parse_args ! ( cx, client_name: String , client_version: String ) ;
507
501
508
502
let res = with_client ( client_name, client_version, |client| {
509
- Ok ( client. get_organizations ( ) . map_err ( Box :: new ) ?)
503
+ Ok ( client. get_organizations ( ) ?)
510
504
} ) ;
511
505
convert_res ( & mut cx, res)
512
506
}
@@ -520,7 +514,7 @@ fn get_unread_reviews(mut cx: FunctionContext) -> JsResult<JsValue> {
520
514
) ;
521
515
522
516
let res = with_client ( client_name, client_version, |client| {
523
- Ok ( client. get_unread_reviews ( course_id) . map_err ( Box :: new ) ?)
517
+ Ok ( client. get_unread_reviews ( course_id) ?)
524
518
} ) ;
525
519
convert_res ( & mut cx, res)
526
520
}
@@ -599,9 +593,7 @@ fn mark_review_as_read(mut cx: FunctionContext) -> JsResult<JsValue> {
599
593
) ;
600
594
601
595
let res = with_client ( client_name, client_version, |client| {
602
- Ok ( client
603
- . mark_review_as_read ( course_id, review_id)
604
- . map_err ( Box :: new) ?)
596
+ Ok ( client. mark_review_as_read ( course_id, review_id) ?)
605
597
} ) ;
606
598
convert_res ( & mut cx, res)
607
599
}
@@ -620,9 +612,7 @@ fn paste(mut cx: FunctionContext) -> JsResult<JsValue> {
620
612
621
613
let locale = locale. map ( |l| Language :: from_639_3 ( & l) . expect ( "Invalid locale" ) ) ;
622
614
let res = with_client ( client_name, client_version, |client| {
623
- Ok ( client
624
- . paste ( exercise_id, & submission_path, paste_message, locale)
625
- . map_err ( Box :: new) ?)
615
+ Ok ( client. paste ( exercise_id, & submission_path, paste_message, locale) ?)
626
616
} ) ;
627
617
convert_res ( & mut cx, res)
628
618
}
@@ -641,14 +631,12 @@ fn request_code_review(mut cx: FunctionContext) -> JsResult<JsValue> {
641
631
642
632
let locale = Language :: from_639_3 ( & locale) . expect ( "Invalid locale" ) ;
643
633
let res = with_client ( client_name, client_version, |client| {
644
- Ok ( client
645
- . request_code_review (
646
- exercise_id,
647
- & submission_path,
648
- message_for_reviewer,
649
- Some ( locale) ,
650
- )
651
- . map_err ( Box :: new) ?)
634
+ Ok ( client. request_code_review (
635
+ exercise_id,
636
+ & submission_path,
637
+ message_for_reviewer,
638
+ Some ( locale) ,
639
+ ) ?)
652
640
} ) ;
653
641
convert_res ( & mut cx, res)
654
642
}
@@ -666,9 +654,7 @@ fn reset_exercise(mut cx: FunctionContext) -> JsResult<JsValue> {
666
654
667
655
let res = with_client ( client_name, client_version, |client| {
668
656
if save_old_state {
669
- client
670
- . submit ( exercise_id, & exercise_path, None )
671
- . map_err ( Box :: new) ?;
657
+ client. submit ( exercise_id, & exercise_path, None ) ?;
672
658
}
673
659
tmc_langs:: reset ( client, exercise_id, & exercise_path)
674
660
} ) ;
@@ -692,9 +678,7 @@ fn send_feedback(mut cx: FunctionContext) -> JsResult<JsValue> {
692
678
} )
693
679
. collect ( ) ;
694
680
let res = with_client ( client_name, client_version, |client| {
695
- Ok ( client
696
- . send_feedback ( submission_id, feedback)
697
- . map_err ( Box :: new) ?)
681
+ Ok ( client. send_feedback ( submission_id, feedback) ?)
698
682
} ) ;
699
683
convert_res ( & mut cx, res)
700
684
}
@@ -717,19 +701,15 @@ fn submit(mut cx: FunctionContext) -> JsResult<JsValue> {
717
701
718
702
let locale = locale. map ( |l| Language :: from_639_3 ( & l) . expect ( "Invalid locale" ) ) ;
719
703
let temp = with_client ( client_name, client_version, |client| {
720
- let new_submission = client
721
- . submit ( exercise_id, & submission_path, locale)
722
- . map_err ( Box :: new) ?;
704
+ let new_submission = client. submit ( exercise_id, & submission_path, locale) ?;
723
705
if dont_block {
724
706
Ok ( Temp :: NewSubmission ( new_submission) )
725
707
} else {
726
708
let submission_url = new_submission
727
709
. submission_url
728
710
. parse ( )
729
711
. expect ( "Failed to parse submission URL" ) ;
730
- let finished = client
731
- . wait_for_submission_at ( submission_url)
732
- . map_err ( Box :: new) ?;
712
+ let finished = client. wait_for_submission_at ( submission_url) ?;
733
713
Ok ( Temp :: Finished ( Box :: new ( finished) ) )
734
714
}
735
715
} )
@@ -760,9 +740,7 @@ fn wait_for_submission(mut cx: FunctionContext) -> JsResult<JsValue> {
760
740
) ;
761
741
762
742
let res = with_client ( client_name, client_version, |client| {
763
- Ok ( client
764
- . wait_for_submission ( submission_id)
765
- . map_err ( Box :: new) ?)
743
+ Ok ( client. wait_for_submission ( submission_id) ?)
766
744
} ) ;
767
745
convert_res ( & mut cx, res)
768
746
}
0 commit comments