Created
November 3, 2011 15:00
-
-
Save miyagawa/1336706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/autodie/exception.pm b/lib/autodie/exception.pm | |
index 14d5cb0..d0e2a4f 100644 | |
--- a/lib/autodie/exception.pm | |
+++ b/lib/autodie/exception.pm | |
@@ -396,7 +396,7 @@ sub _format_open_with_mode { | |
return sprintf _FORMAT_OPEN, $file, $wordy_mode, $error if $wordy_mode; | |
- Carp::confess("Internal autodie::exception error: Don't know how to format mode '$mode'."); | |
+ return; | |
} | |
@@ -458,9 +458,7 @@ sub _format_open { | |
my $mode = $open_args[1]; | |
- local $@; | |
- | |
- my $msg = eval { $this->_format_open_with_mode($mode, $file, $!); }; | |
+ my $msg = $this->_format_open_with_mode($mode, $file, $!); | |
return $msg if $msg; | |
diff --git a/t/open.t b/t/open.t | |
index 67f6f0c..5ce295f 100755 | |
--- a/t/open.t | |
+++ b/t/open.t | |
@@ -76,3 +76,17 @@ SKIP: { | |
is $@, '', "multi arg piped open does not fail"; | |
} | |
+ | |
+eval { | |
+ open my $fh, '<:utf8', 'README'; | |
+}; | |
+ | |
+SKIP: { | |
+ skip('PerlIO not supported on this perl', 1) if $@; | |
+ eval { | |
+ use autodie; | |
+ open my $fh, '<:utf8', '/non/existent/path'; | |
+ }; | |
+ | |
+ like $@, qr!^Can't open '/non/existent/path' with mode '<:utf8':!, "open error with PerlIO captured"; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment