~ubuntu-branches/ubuntu/precise/bioperl/precise

« back to all changes in this revision

Viewing changes to Bio/Root/Exception.pm

  • Committer: Bazaar Package Importer
  • Author(s): Ilya Barygin
  • Date: 2010-01-27 22:48:22 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100127224822-ebot4qbrjxcv38au
Tags: 1.6.1-1ubuntu1
* Merge from Debian testing, remaining changes:
  - disable tests, they produce a FTBFS trying to access the network 
    during run.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#-----------------------------------------------------------------
2
 
# $Id: Exception.pm 15171 2008-12-16 03:28:01Z cjfields $
 
2
# $Id: Exception.pm 16123 2009-09-17 12:57:27Z cjfields $
3
3
#
4
4
# BioPerl module Bio::Root::Exception
5
5
#
 
6
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
 
7
#
6
8
# Cared for by Steve Chervitz <sac@bioperl.org>
7
9
#
8
10
# You may distribute this module under the same terms as perl itself
14
16
 
15
17
=head1 SYNOPSIS
16
18
 
17
 
=head2 Throwing exceptions using L<Error::throw()>:
 
19
=head2 Throwing exceptions using L<Error.pm throw|Error::throw>:
18
20
 
19
21
    use Bio::Root::Exception;
20
22
    use Error;
26
28
    open (IN, $file) ||
27
29
            throw Bio::Root::FileOpenException ( "Can't open file $file for reading", $!);
28
30
 
29
 
=head2 Throwing exceptions using L<Bio::Root::Root::throw()>:
 
31
=head2 Throwing exceptions using L<Bioperl throw|Bio::Root::Root/throw>:
30
32
 
31
33
     # Here we have an object that ISA Bio::Root::Root, so it inherits throw().
32
34
 
35
37
                               -text => "Can't open file $file for reading",
36
38
                               -value => $!);
37
39
 
38
 
=head2 Catching and handling exceptions using L<Error::try()>:
 
40
=head2 Catching and handling exceptions using L<Error.pm try|Error/try>:
39
41
 
40
42
    use Bio::Root::Exception;
41
43
    use Error qw(:try);
73
75
 
74
76
    @Bio::TestException::ISA = qw( Bio::Root::Exception );
75
77
 
76
 
 
77
78
=head1 DESCRIPTION
78
79
 
79
80
=head2 Exceptions defined in L<Bio::Root::Exception>
143
144
Error.pm is not part of the Bioperl distibution, and may not be
144
145
present within  any given perl installation. So, when you want to 
145
146
throw an exception in a Bioperl module, the safe way to throw it
146
 
is to use L<Bio::Root::Root::throw()> which can use Error.pm 
 
147
is to use L<Bio::Root::Root/throw> which can use Error.pm 
147
148
when it's available. See documentation in Bio::Root::Root for details.
148
149
 
149
150
=head1 SEE ALSO
151
152
See the C<examples/exceptions> directory of the Bioperl distribution for 
152
153
working demo code.
153
154
 
154
 
L<Bio::Root::Root::throw()> for information about throwing 
 
155
L<Bio::Root::Root/throw> for information about throwing 
155
156
L<Bio::Root::Exception>-based exceptions.
156
157
 
157
158
L<Error> (available from CPAN, author: GBARR)
206
207
@Bio::Root::Exception::ISA = qw( Error );
207
208
#---------------------------------------------------------
208
209
 
209
 
=head2 Methods defined by Bio::Root::Exception
210
 
 
211
 
=over 4
212
 
 
213
 
=item L<new()>
 
210
=head1 Methods defined by Bio::Root::Exception
 
211
 
 
212
=head2 new
214
213
 
215
214
 Purpose : Guarantees that -value is set properly before
216
215
           calling Error::new().
262
261
    return $self;
263
262
}
264
263
 
265
 
=item pretty_format()
 
264
=head2 pretty_format()
266
265
 
267
266
 Purpose : Get a nicely formatted string containing information about the 
268
267
           exception. Format is similar to that produced by 
339
338
    return join "\n", @new_stack;
340
339
}
341
340
 
342
 
=item L<stringify()>
 
341
=head2 stringify()
343
342
 
344
343
 Purpose : Overrides Error::stringify() to call pretty_format(). 
345
344
           This is called automatically when an exception object 
358
357
    return $self->pretty_format( @args );
359
358
}
360
359
 
361
 
 
362
 
 
363
 
=back
364
 
 
365
360
=head1 Subclasses of Bio::Root::Exception 
366
361
 
367
 
 
368
362
=head2 L<Bio::Root::NotImplemented>
369
363
 
370
364
 Purpose : Indicates that a method has not been implemented.