|
NAMESPOPS::Exception::DBI - SPOPS exception with extra DBI parametersSYNOPSISmy $rows = eval { SPOPS::SQLInterface->db_select( \%params ) }; if ( $@ and $@->isa( 'SPOPS::Exception::DBI' ) ) { print "Tried to excecute SQL: ", $@->sql, "\n", "with values: ", ( ref $@->bound_value ) ? join( " :: ", @{ $@->bound_value } ) : 'n/a', "but died with the message: ", $@->message, "\n"; } DESCRIPTIONSame as SPOPS::Exception but we add three new properties:sql ($) The SQL statement SPOPS tried to run. Note that this may be empty if the exception was thrown before the statement could be prepared. (For instance, if SPOPS cannot find a datasource.) bound_value (\@) The value(s) that would have been bound to the various placeholders. This may return undef if SPOPS did not reach the stage where it collected the bound values or if there were none. So you will want to test and ensure the return value is an arrayref before using it as such, otherwise you will get the dreaded error: "Can't use an undefined value as an ARRAY reference". action ($) Indicates the DBI action (generally 'do', 'prepare' or 'execute') that was being run when SPOPS encountered the error. This may be empty if we did not even reach the DBI stage yet. METHODSNo extra methods, but we override 'to_string' so any SQL executed will be part of the error.Additionally, you can use a shortcut if you are throwing errors: use SPOPS::Exception::DBI qw( spops_dbi_error ); ... spops_dbi_error "I found a DBI error: $@ ", { sql => $sql, action => 'prepare' }; BUGSNone known.TO DONothing known.SEE ALSOSPOPS::ExceptionDBI COPYRIGHTCopyright (c) 2001-2004 intes.net, inc.. All rights reserved.This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHORSChris Winters <chris@cwinters.com>
Visit the GSP FreeBSD Man Page Interface. |