=head1 NAME

SPOPS::Manual::Error - SPOPS Error handling

=head1 DESCRIPTION

Error handling in SPOPS is fairly straightforward. Most (if not all)
methods that can encounter some sort of error let the caller know
about the error by throwing a C<die>. The error thrown is a simple
error message -- additional information can be inspected through
variables in L<SPOPS::Error|SPOPS::Error>.

The variables used are:

B<user_msg> ($)

A generic message that is suitable for showing a user. When telling a
user something went wrong, you do not want to tell them:

 execute called with 2 bind variables when 1 are needed

instead, you want to tell them:

 Database query failed to execute

Typically, this is the message that the SPOPS class will C<die()>
with.

B<system_msg> ($)

Even though you do not want to show your users details of the error,
you still need to know them! The variable I<system_msg> gives you
details regarding the error.

B<type> ($)

SPOPS knows about a few types of errors. Some depend on your SPOPS
implementation (e.g., DBI, dbm, LDAP, etc.). Others can be:

=over 4

=item *

B<security>: There is a security violation and the action could not be
completed

=back

B<package> ($)

Set to the package from where the error was thrown.

B<method> ($)

Set to the method from where the error was thrown. (If set
automatically, this is a fully-qualified subroutine name.)

B<filename> ($)

Set to the filename from where the error was thrown.

B<line> ($)

Set to the line number from where the error was thrown.

B<extra> (\%)

Different SPOPS classes have different information related to the
current request. For instance, DBI errors will typically fill the
'sql' and 'values' keys. Other SPOPS implementations may use different
keys; see their documentation for details.

=head1 EXAMPLES

  1: my $news_id = $q->param( 'news_id' );
  2: my $news = eval { My::News->fetch( $news_id ) }
  3: if ( $@ ) {
  4:     my $error_info = SPOPS::Error->get;
  5:     log_error( $error_info );
  6:     if ( $error_info->{type} eq 'security' ) {
  7:         print "Cannot retrieve News article -- security violation.";
  8:     }
  9:     else {
 10:         print "Cannot retrieve News article! Please contact administrator.";
 11:     }
 12: }
 13: 
 14: print "$news->{title}\n$news->{posted_on}\n$news->{content}\n";

=head1 COPYRIGHT

Copyright (c) 2001 Chris Winters. All rights reserved.

See L<SPOPS::Manual|SPOPS::Manual> for license.

=head1 AUTHORS

Chris Winters <chris@cwinters.com>