@@ -611,11 +611,8 @@ public static long chmod(String path, long mode, ThreadContext tc) {
611
611
Set <PosixFilePermission > perms = modeToPosixFilePermission (mode );
612
612
Files .setPosixFilePermissions (path_o , perms );
613
613
}
614
- catch (IOException e ) {
615
- die_s ("nqp::chmod: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
616
- }
617
614
catch (Exception e ) {
618
- die_s ("nqp::chmod: unhandled exception" , tc );
615
+ die_s (IOExceptionMessages . message ( e ) , tc );
619
616
}
620
617
return 0 ;
621
618
}
@@ -626,11 +623,8 @@ public static long unlink(String path, ThreadContext tc) {
626
623
return -2 ;
627
624
}
628
625
}
629
- catch (IOException e ) {
630
- die_s ("nqp::unlink: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
631
- }
632
626
catch (Exception e ) {
633
- die_s ("nqp::unlink: unhandled exception" , tc );
627
+ die_s (IOExceptionMessages . message ( e ) , tc );
634
628
}
635
629
return 0 ;
636
630
}
@@ -643,11 +637,8 @@ public static long rmdir(String path, ThreadContext tc) {
643
637
}
644
638
Files .delete (path_o );
645
639
}
646
- catch (IOException e ) {
647
- die_s ("nqp::rmdir: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
648
- }
649
640
catch (Exception e ) {
650
- die_s ("nqp::rmdir: unhandled exception" , tc );
641
+ die_s (IOExceptionMessages . message ( e ) , tc );
651
642
}
652
643
return 0 ;
653
644
}
@@ -666,13 +657,9 @@ public static long mkdir(String path, long mode, ThreadContext tc) {
666
657
Files .createDirectory (Paths .get (path ),
667
658
PosixFilePermissions .asFileAttribute (modeToPosixFilePermission (mode )));
668
659
}
669
- catch (IOException e ) {
670
- die_s ("nqp::mkdir: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
671
- }
672
660
catch (Exception e ) {
673
- die_s ("nqp::mkdir: unhandled exception" , tc );
661
+ die_s (IOExceptionMessages . message ( e ) , tc );
674
662
}
675
-
676
663
return 0 ;
677
664
}
678
665
@@ -682,11 +669,8 @@ public static long rename(String before, String after, ThreadContext tc) {
682
669
try {
683
670
Files .move (before_o , after_o );
684
671
}
685
- catch (IOException e ) {
686
- die_s ("nqp::rename: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
687
- }
688
672
catch (Exception e ) {
689
- die_s ("nqp::rename: unhandled exception" , tc );
673
+ die_s (IOExceptionMessages . message ( e ) , tc );
690
674
}
691
675
return 0 ;
692
676
}
@@ -697,11 +681,8 @@ public static long copy(String before, String after, ThreadContext tc) {
697
681
try {
698
682
Files .copy (before_o , after_o );
699
683
}
700
- catch (IOException e ) {
701
- die_s ("nqp::copy: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
702
- }
703
684
catch (Exception e ) {
704
- die_s ("nqp::copy: unhandled exception" , tc );
685
+ die_s (IOExceptionMessages . message ( e ) , tc );
705
686
}
706
687
return 0 ;
707
688
}
@@ -712,11 +693,8 @@ public static long link(String before, String after, ThreadContext tc) {
712
693
try {
713
694
Files .createLink (before_o , after_o );
714
695
}
715
- catch (IOException e ) {
716
- die_s ("nqp::link: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
717
- }
718
696
catch (Exception e ) {
719
- die_s ("nqp::link: unhandled exception" , tc );
697
+ die_s (IOExceptionMessages . message ( e ) , tc );
720
698
}
721
699
return 0 ;
722
700
}
@@ -768,11 +746,8 @@ public static long symlink(String before, String after, ThreadContext tc) {
768
746
try {
769
747
Files .createSymbolicLink (before_o , after_o );
770
748
}
771
- catch (IOException e ) {
772
- die_s ("nqp::symlink: " + e .getClass ().getSimpleName () + ": " + e .getMessage (), tc );
773
- }
774
749
catch (Exception e ) {
775
- die_s ("nqp::symlink: unhandled exception" , tc );
750
+ die_s (IOExceptionMessages . message ( e ) , tc );
776
751
}
777
752
return 0 ;
778
753
}
0 commit comments