[Bioperl-l] how to catch exception error

Heikki Lehvaslaiho heikki@ebi.ac.uk
Fri, 07 Jun 2002 10:56:05 +0100


Damien,

Write:


eval {
     $seq = $gb->get_Seq_by_acc($acc);
};
print "$@ Could not retrieve $acc\n" if $@;

Yours,
	-Heikki


Damien Mattei wrote:
> 
> when doing something like this:
> 
> use Bio::DB::GenBank;
> 
> $gb = new Bio::DB::GenBank();
> 
> # this returns a Seq object :
> $seq = $gb->get_Seq_by_acc("AC019220");
> 
> i get an exception that stop my program:
> ------------- EXCEPTION  -------------
> MSG: WebDBSeqI Request Error
> 
> STACK Bio::DB::WebDBSeqI::_request 
> /usr/lib/perl5/site_perl/5.6.1/Bio/DB/WebDBSeqI.pm:523
> STACK Bio::DB::WebDBSeqI::get_seq_stream 
> /usr/lib/perl5/site_perl/5.6.1/Bio/DB/WebDBSeqI.pm:375
> STACK Bio::DB::NCBIHelper::get_Stream_by_acc 
> /usr/lib/perl5/site_perl/5.6.1/Bio/DB/NCBIHelper.pm:466
> STACK Bio::DB::WebDBSeqI::get_Seq_by_acc 
> /usr/lib/perl5/site_perl/5.6.1/Bio/DB/WebDBSeqI.pm:161
> STACK main::nxtbac ./gmap.pl:338
> STACK toplevel ./gmap.pl:25
> 
> --------------------------------------
> 
> 
> is there a way in bioperl to catch exception
> as it is possible in Java or C++ ?
> 
> 
> Damien Mattei
> C.N.R.S / U.N.S.A - UMR 6549
> mailto:mattei@unice.fr
> http://www-iag.unice.fr/
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l


-- 
______ _/      _/_____________________________________________________
       _/      _/                      http://www.ebi.ac.uk/mutations/
      _/  _/  _/  Heikki Lehvaslaiho          heikki@ebi.ac.uk
     _/_/_/_/_/  EMBL Outstation, European Bioinformatics Institute
    _/  _/  _/  Wellcome Trust Genome Campus, Hinxton
   _/  _/  _/  Cambs. CB10 1SD, United Kingdom
      _/      Phone: +44 (0)1223 494 644   FAX: +44 (0)1223 494 468
___ _/_/_/_/_/________________________________________________________