ã¡ã¢: Error.pm ã§ãµãã¯ã©ã¹åããä¾å¤ãæãã
ä¾å¤ãæããã¨ã㯠$obj->throwããã¼ã¹ã¯ã©ã¹ã¯ Error::Simpleã
try { MyException->new("hello world")->throw; } catch MyException with { my $e = shift; print "$e\n"; }; package MyException; use base qw(Error::Simple);
ã¿ããæ¸ããè²ã æãã¦ããã£ãçµæç解ãããmiyagawa++ tokuhirom++
8/28追è¨: ã¡ãªã¿ã« Error::Simple ãã»ãããã $@ ã¯ä¾å¤ã¨ãã¦éåºããããªãã¸ã§ã¯ãã§ãã㤠Error::Simple 㯠stringify ããªã¼ãã¼ã©ã¤ããã¦ããã®ã§ãeval ã使ã£ã¦ä¾å¤ç£è¦ãã¦ããå ´åãã¡ããã¨åãã
eval { MyException->new("hello world")->throw; }; if ($@) { print ref $@; # prints MyException print $@; # prints "hello world" }