Skip to content

Commit

Permalink
Make X::OS "is Exception".
Browse files Browse the repository at this point in the history
It now passes it on to the various classes that do it, much as we do
with X::Comp. This in turn means using X::OS and X::IO directly will
give something that type matches Exception.
  • Loading branch information
jnthn committed May 15, 2015
1 parent 255d365 commit d02b4c0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/core/Exception.pm
Original file line number Diff line number Diff line change
Expand Up @@ -253,45 +253,45 @@ do {

}

my role X::OS {
my role X::OS is Exception {
has $.os-error;
}

my role X::IO does X::OS { };

my class X::IO::Rename does X::IO is Exception {
my class X::IO::Rename does X::IO {
has $.from;
has $.to;
method message() {
"Failed to rename '$.from' to '$.to': $.os-error"
}
}

my class X::IO::Copy does X::IO is Exception {
my class X::IO::Copy does X::IO {
has $.from;
has $.to;
method message() {
"Failed to copy '$.from' to '$.to': $.os-error"
}
}

my class X::IO::DoesNotExist does X::IO is Exception {
my class X::IO::DoesNotExist does X::IO {
has $.path;
has $.trying;
method message() {
"Failed to find '$.path' while trying to do '.$.trying'"
}
}

my class X::IO::NotAFile does X::IO is Exception {
my class X::IO::NotAFile does X::IO {
has $.path;
has $.trying;
method message() {
"'$.path' is not a regular file while trying to do '.$.trying'"
}
}

my class X::IO::Directory does X::IO is Exception {
my class X::IO::Directory does X::IO {
has $.path;
has $.trying;
has $.use;
Expand All @@ -302,65 +302,65 @@ my class X::IO::Directory does X::IO is Exception {
}
}

my class X::IO::Symlink does X::IO is Exception {
my class X::IO::Symlink does X::IO {
has $.target;
has $.name;
method message() {
"Failed to create symlink called '$.name' on target '$.target': $.os-error"
}
}

my class X::IO::Link does X::IO is Exception {
my class X::IO::Link does X::IO {
has $.target;
has $.name;
method message() {
"Failed to create link called '$.name' on target '$.target': $.os-error"
}
}

my class X::IO::Mkdir does X::IO is Exception {
my class X::IO::Mkdir does X::IO {
has $.path;
has $.mode;
method message() {
"Failed to create directory '$.path' with mode '0o{$.mode.fmt("%03o")}': $.os-error"
}
}

my class X::IO::Chdir does X::IO is Exception {
my class X::IO::Chdir does X::IO {
has $.path;
method message() {
"Failed to change the working directory to '$.path': $.os-error"
}
}

my class X::IO::Dir does X::IO is Exception {
my class X::IO::Dir does X::IO {
has $.path;
method message() {
"Failed to get the directory contents of '$.path': $.os-error"
}
}

my class X::IO::Cwd does X::IO is Exception {
my class X::IO::Cwd does X::IO {
method message() {
"Failed to get the working directory: $.os-error"
}
}

my class X::IO::Rmdir does X::IO is Exception {
my class X::IO::Rmdir does X::IO {
has $.path;
method message() {
"Failed to remove the directory '$.path': $.os-error"
}
}

my class X::IO::Unlink does X::IO is Exception {
my class X::IO::Unlink does X::IO {
has $.path;
method message() {
"Failed to remove the file '$.path': $.os-error"
}
}

my class X::IO::Chmod does X::IO is Exception {
my class X::IO::Chmod does X::IO {
has $.path;
has $.mode;
method message() {
Expand Down

0 comments on commit d02b4c0

Please sign in to comment.