Course of Raku / Objects, I/O, and exceptions / Exceptions / Exception objects / Exercises / Prefix the message
Solution: Prefix the message
Here is a possible solution to the task.
Code
{
die 'timeout';
CATCH {
default {
say 'Error: ' ~ .message;
}
}
}🦋 You can find the source code in the file error-prefix.raku.
Output
Error: timeoutComments
The exception object’s
.messagegives the text passed todie.Concatenating it after
Error:builds the final line. The exception object is just a value, so you can use its message however you like.