Skip to content

Commit

Permalink
[io grant] Make IO::Handle.flush fail with typed exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed May 13, 2017
1 parent 85230d0 commit b43ed18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -552,6 +552,12 @@ my class X::IO::Cwd does X::IO {
}
}

my class X::IO::Flush does X::IO {
method message() {
"Cannot flush handle: $.os-error"
}
}

my class X::IO::NotAChild does X::IO {
has $.path;
has $.child;
Expand Down
4 changes: 2 additions & 2 deletions src/core/IO/Handle.pm
Expand Up @@ -593,8 +593,8 @@ my class IO::Handle {


method flush(IO::Handle:D: --> True) {
fail("File handle not open, so cannot flush")
unless nqp::defined($!PIO);
CATCH { default { fail X::IO::Flush.new: :os-error(.Str) } }
nqp::defined($!PIO) or die 'File handle not open, so cannot flush';
nqp::flushfh($!PIO);
}

Expand Down

0 comments on commit b43ed18

Please sign in to comment.