from-slurpy
ErrorsCollection

from-slurpy

Synthesised documentation from type/X/AdHoc

From type/X/AdHoc

See Original text in context

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.

try {
    X::AdHoc.from-slurpy3False"Not here" ).throw
};
print $!.payload.^name# OUTPUT: «Capture+{X::AdHoc::SlurpySentry}» 
print $!.message;       # OUTPUT: «3FalseNot here» 

The SlurpySentry role joins the elements of the payload, instead of directly converting them to a string.