Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change some nqp::die's to $*W.throw to get file/line
This also means better testability. There are still a bunch of
nqp::die's left.
  • Loading branch information
FROGGS committed Oct 6, 2015
1 parent 02e6198 commit 164953b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -2718,7 +2718,8 @@ Compilation unit '$file' contained the following violations:
$U := 1;
}
else {
nqp::die("Unsupported type smiley '" ~ $_<identifier>.Str ~ "' used in type name");
$*W.throw($/, ['X', 'InvalidTypeSmiley'],
name => $_<identifier>.Str)
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Perl6/World.nqp
Expand Up @@ -638,7 +638,8 @@ class Perl6::World is HLL::World {
self.import($/, self.stash_hash($EXPORT{$tag}), $package_source_name);
}
else {
nqp::die("Error while importing from '$package_source_name': no such tag '$tag'");
self.throw($/, ['X', 'Import', 'NoSuchTag'],
source-package => $package_source_name, :$tag)
}
}
else {
Expand Down Expand Up @@ -667,8 +668,8 @@ class Perl6::World is HLL::World {
}
else {
if +@positional_imports {
nqp::die("Error while importing from '$package_source_name':
no EXPORT sub, but you provided positional argument in the 'use' statement");
self.throw($/, ['X', 'Import', 'Positional'],
source-package => $package_source_name)
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -1885,6 +1885,22 @@ my class X::Import::MissingSymbols is Exception {
}
}

my class X::Import::NoSuchTag is Exception {
has $.source-package;
has $.tag;
method message() {
"Error while importing from '$.source-package': no such tag '$.tag'"
}
}

my class X::Import::Positional is Exception {
has $.source-package;
method message() {
"Error while importing from '$.source-package':\n"
~ "no EXPORT sub, but you provided positional argument in the 'use' statement"
}
}

my class X::Numeric::Real is Exception {
has $.target;
has $.reason;
Expand Down Expand Up @@ -2143,6 +2159,13 @@ my class X::InvalidType does X::Comp {
}
}

my class X::InvalidTypeSmiley does X::Comp {
has $.name;
method message() {
"Invalid type smiley '$.name' used in type name";
}
}

my class X::Seq::Consumed is Exception {
method message() {
"This Seq has already been iterated, and its values consumed"
Expand Down

0 comments on commit 164953b

Please sign in to comment.