develooper Front page | perl.perl6.language | Postings from January 2010

Re: Custom errors on subsets?

Thread Previous | Thread Next
From:
yary
Date:
January 4, 2010 10:03
Subject:
Re: Custom errors on subsets?
Message ID:
75cbfa571001041002m15f31f1bhda7fc6df1c855ef3@mail.gmail.com
On Mon, Jan 4, 2010 at 5:15 AM, Ovid
<publiustemp-perl6language2@yahoo.com> wrote:
> Given this code:
>
>    subset Filename of Str where { $_ ~~ :f };
>
>    sub foo (Filename $name) {
>        say "Houston, we have a filename: $name";
>    }
...
> Obviously the error message can use some work, but how would I customize that error message (assuming such will be possible in the future)?  Clearly there will be many cases where a custom error message for constraint failure could make life much easier for developers.


How about
multi sub foo(Any $name) { die "Houston, we have a major malfunction."}

-y

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About