Skip to content

Commit

Permalink
- Adds an .origin field to the X::Cro::Uri::ParseError exception so t…
Browse files Browse the repository at this point in the history
…hat consuming code can add origination information if so desired.
  • Loading branch information
Xliff committed Sep 21, 2024
1 parent 42a55a8 commit 66b03ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Cro/Uri.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ package EXPORT::decode-percents {
class X::Cro::Uri::ParseError is Exception {
has $.reason = 'malformed syntax';
has $.uri-string is required;
has $.origin;

method message() {
"Unable to parse URI '$!uri-string': $!reason"
[~](
"Unable to parse URI '$!uri-string'",
($.origin ?? " from { $!origin }" !! ''),
": $!reason"
)
}
}

Expand Down Expand Up @@ -548,4 +554,4 @@ class Cro::Uri does Cro::ResourceIdentifier {
token modifier-level4 { <prefix> | '*' }
token prefix { ':' <[\x31..\x39]> \d ** 0..3 }
}
}
}

0 comments on commit 66b03ef

Please sign in to comment.