App-Context

 view release on metacpan or  search on metacpan

lib/App/exceptions.pod  view on Meta::CPAN

#!perl -w
# run this document through perl to check its syntax
use Pod::Checker;
podchecker(\*DATA);
__END__

=head1 NAME

App::exceptions - Programming with Exceptions

=head1 INTRODUCTION

Programming with Exceptions
is a much more reliable way to prepare for unusual conditions
than trying to handle error codes returned from functions and methods
That is why programming with exceptions is an Enterprise Programming
topic.  However, Perl has not always supported programming with
exceptions, and many Perl programmers are not familiar with this
style of programming using Perl.

This document was written to explain the support within the Perl
language for programming using exceptions in general.  It also explains
the standards for exception programming in the App-Context framework.

The short answer is that we recommend the following modules
to assist in exception programming.

  Carp
  CGI::Carp
  Fatal
  Exception::Class
  Devel::Stacktrace

However, it is important to understand what each does for you,
why, and how they all fit together.
So for the longer answer, read on.

=head1 IMPORTANCE OF EXCEPTION PROGRAMMING

Exception Programming is a technique to deal with exceptional 
conditions (i.e. errors) encountered during runtime. 
It is contrasted with the more common technique of 
Error Checking.

Error Checking is a technique where an operation is performed.
Then all possible error conditions are checked and handled.
This requires the developer to address the following challenges.

=over

=item 1. Error Completeness

The developer must consider all possible error conditions
(difficult to foresee and consider at every level).

=item 2. Error Propagation

The developer must add quite a bit of additional logic
to allow subsequent statements after the error condition
to be skipped and the error to be propagated upward in
the call stack to the place where
it can be acted on appropriately.

=back

The problems with Error Checking is that it is so difficult
to do and so rarely done completely. 
Since the program runs fine when no errors are
encountered, the developer invariably fails to put in all of
the error checks and the accompanying error propagation logic.

Exception Programming addresses these problems using the
following methods.

=over

=item 1. Error Completeness

Exceptions are grouped into an exception hierarchy.
Therefore, high level code needs only make the distinctions
between exceptions that it thinks are relevant.  If additional
exceptions are added later by low level code, they will be
handled in accordance with the upper levels of the exception



( run in 1.405 second using v1.01-cache-2.11-cpan-e1769b4cff6 )