[Bioperl-l] Bio::Root::RootI->throw($msg,$class) overloading?
Hilmar Lapp
hlapp at gmx.net
Tue Jul 11 19:05:03 UTC 2006
I think it does this already, except that I believe you need to
create the exception object and initialize with the message upfront.
Steve, can you comment? Is this at least somewhat right?
-hilmar
On Jul 11, 2006, at 4:58 AM, Rutger Vos wrote:
> Dear all,
>
> would it be possible to overload Bio::Root::RootI's 'throw' method to
> accept an additional, optional (positional) argument to define the
> exception class, e.g. using Exception::Class:
>
> # ...somewhere ...
>
> sub makefh {
> my ( $self, $filename ) = @_;
> open my $fh, '<' $filename or $self->throw("Can't open file: $!",
> 'Bio::Exceptions::FileIO'); # NOTE second argument
> return $fh;
> }
>
> #.... somewhere else
> my $fh;
> eval {
> $fh = $obj->makefh( 'data.txt');
> }
> if ( $@ and $@->isa('Bio::Exceptions::FileIO') ) {
> # something's wrong with the file?
> }
>
> --
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> Rutger Vos, PhD. candidate
> Department of Biological Sciences
> Simon Fraser University
> 8888 University Drive
> Burnaby, BC, V5A1S6
> Phone: 604-291-5625
> Fax: 604-291-3496
> Personal site: http://www.sfu.ca/~rvosa
> FAB* lab: http://www.sfu.ca/~fabstar
> Bio::Phylo: http://search.cpan.org/~rvosa/Bio-Phylo/
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
--
===========================================================
: Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net :
===========================================================
More information about the Bioperl-l
mailing list