Skip to content

Commit 6f3550f

Browse files
committedMar 9, 2018
rename exception class
1 parent ab40e77 commit 6f3550f

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed
 

‎lib/SemiXML.pm6

+16-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ package SemiXML:auth<github:MARTIMM> {
2626
}
2727

2828
#-------------------------------------------------------------------------------
29-
class X::SemiXML is Exception {
29+
class X::SemiXML::Parse is Exception {
3030

3131
has Str $.message;
3232

@@ -36,5 +36,19 @@ class X::SemiXML is Exception {
3636
#-----------------------------------------------------------------------------
3737
# prevent a stackdump, see 'Uncaught Exceptions' at
3838
# https://docs.perl6.org/language/exceptions#Catching_exceptions
39-
multi method gist(X::SemiXML:D:) { $.message }
39+
multi method gist(X::SemiXML::Parse:D:) { $.message }
40+
}
41+
42+
#-------------------------------------------------------------------------------
43+
class X::SemiXML::Core is Exception {
44+
45+
has Str $.message;
46+
47+
#-----------------------------------------------------------------------------
48+
submethod BUILD ( :$!message ) { }
49+
50+
#-----------------------------------------------------------------------------
51+
# prevent a stackdump, see 'Uncaught Exceptions' at
52+
# https://docs.perl6.org/language/exceptions#Catching_exceptions
53+
multi method gist(X::SemiXML::Core:D:) { $.message }
4054
}

‎lib/SemiXML/Element.pm6

+2-2
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,15 @@ class Element does SemiXML::Node {
543543
my $object = $objects{$!module} if $objects{$!module}:exists;
544544

545545
if $object.defined {
546-
die X::SemiXML.new(
546+
die X::SemiXML::Parse.new(
547547
:message(
548548
"Method $!method in module $!module ($object.^name()) not defined"
549549
)
550550
) unless $object.^can($!method);
551551
}
552552

553553
else {
554-
die X::SemiXML.new(:message("Module $!module not defined"));
554+
die X::SemiXML::Parse.new(:message("Module $!module not defined"));
555555
}
556556

557557
$object

‎lib/SemiXML/Grammar.pm6

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ grammar Grammar {
3333
" line $l\n... $t0.substr( *-$i, *-0)", color('red'),
3434
"\x[23CF]", $t1.substr( 0, 28), color('reset'), "\n\n";
3535

36-
my X::SemiXML $x .= new(:$message);
36+
my X::SemiXML::Parse $x .= new(:$message);
3737
die $x;
3838
}
3939

‎t/010-simple.t

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ subtest 'test oneliners', {
1616

1717
throws-like(
1818
{ $xml = parse('$st [ $f w [] hj ]'); },
19-
X::SemiXML, 'Parse failure',
19+
X::SemiXML::Parse, 'Parse failure',
2020
:message(/:s Cannot start a content body/)
2121
);
2222

@@ -75,14 +75,16 @@ sub parse ( Str $content is copy --> Str ) {
7575
my Bool $r = $x.parse(
7676
:$content,
7777
:config( {
78-
T => { :!config, :!parse },
78+
T => { :!config, :parse },
7979
}
80-
)
80+
),
81+
:!trace
8182
);
8283
# $content ~~ s:g/\n/ /;
8384
# $content ~~ s:g/\s+/ /;
8485
# ok $r, "match $content";
8586

87+
#diag ~$x;
8688
~$x
8789
}
8890

‎t/030-methods.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ throws-like {
7979

8080
# exception is thrown when result is retrieved
8181
$x.Str;
82-
}, X::SemiXML, 'Too many nodes on top',
82+
}, X::SemiXML::Core, 'Too many nodes on top',
8383
:message(/:s Too many nodes on top level/);
8484

8585
lives-ok {

0 commit comments

Comments
 (0)
Please sign in to comment.