Skip to content

Commit

Permalink
Changes message string
Browse files Browse the repository at this point in the history
Also DRY by putting it into a constant. Closes Raku/old-issue-tracker#6588 when accepted.
  • Loading branch information
JJ committed Dec 30, 2020
1 parent eb1eabf commit 336a217
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core.c/IO/Path.pm6
Expand Up @@ -6,13 +6,14 @@ my class IO::Path is Cool does IO {
has $!os-path; # the absolute path associated with path/SPEC/CWD
has $!parts; # IO::Path::Parts object, if any

constant empty-path-message = "Must specify a non-empty string as a path";

multi method ACCEPTS(IO::Path:D: Cool:D \other) {
nqp::hllbool(nqp::iseq_s($.absolute, nqp::unbox_s(other.IO.absolute)));
}

method !SET-SELF(Str:D \path, IO::Spec \SPEC, Str:D \CWD, \absolute) {
die "Must specify something as a path: did you mean '.' for the current directory?"
unless nqp::chars(path);
die empty-path-message unless nqp::chars(path);

X::IO::Null.new.throw
if nqp::isne_i(nqp::index(path, "\0"), -1)
Expand Down Expand Up @@ -56,7 +57,7 @@ my class IO::Path is Cool does IO {
$SPEC.join($volume,$dirname,$basename), $SPEC, $CWD.Str, False)
}
multi method new(IO::Path:) {
die "Must specify something as a path: did you mean '.' for the current directory?";
die empty-path-message;
}

method is-absolute(--> Bool:D) {
Expand Down

0 comments on commit 336a217

Please sign in to comment.