X::AdHoc Reference
Error with a custom message
What it is #
Position in the hierarchy #
| Inherits from | — |
| Does | — |
| Inherited by | X::Comp::AdHoc |
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method payload #
Returns the original object which was passed to die.
method Numeric #
method Numeric()
Converts the payload to Numeric and returns it
method from-slurpy #
method from-slurpy (|cap)
Creates a new exception from a capture and returns it. The capture will have the SlurpySentry role mixed in, so that the .message method behaves in a different when printing the message. The SlurpySentry role joins the elements of the payload, instead of directly converting them to a string.
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
2 no-output · 1 rakupp-differs
class X::AdHoc is Exception { }Not executed: the documentation states no expected output for this example.
try {
die [404, 'File not found']; # throw non-exception object
}
print "Got HTTP code ",
$!.payload[0], # 404
" and backtrace ",
$!.backtrace.Str;Not executed: the documentation states no expected output for this example.
try {
X::AdHoc.from-slurpy( 3, False, "Not here" ).throw
};
print $!.payload.^name; # OUTPUT: «Capture+{X::AdHoc::SlurpySentry}»
print $!.message; # OUTPUT: «3FalseNot here»Capture+{X::AdHoc::SlurpySentry}3FalseNot hereCapture+{X::AdHoc::SlurpySentry}3FalseNot hereRaku++ disagrees with both the documentation and Rakudo — a defect.