blib/lib/DBIx/Error.pm

filter: Statementstmt 89.6% 87 / 97 Branchbran 65.3% 17 / 26 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 94.4% 17 / 18 Podpod 100% 4 / 4 totaltotal 83.3% 125 / 150 CC 17 SCAR 18.8
CC
17
Cov
83%
_build_pod
30.0
exception_class
5.0
__ANON__
3.2
CRAP 6.6
↑ Summary
1 package DBIx::Error;
2  
3 # Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>
4 #
5 # This program is free software. You can redistribute it and/or modify
6 # it under the same terms as Perl itself.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  
12 =head1 NAME
13  
14 DBIx::Error - Structured exceptions for DBI
15  
16 =head1 SYNOPSIS
17  
18 use DBIx::Error;
19  
20 # Configure exception handler for DBI
21 my $db = DBI->connect ( $dsn, $user, $password,
22 { HandleError => DBIx::Error->HandleError,
23 ShowErrorStatement => 1 } );
24  
25 # Catch a unique constraint violation (by class name)
26 use TryCatch;
27 try {
28 ...
29 } catch ( DBIx::Error::UniqueViolation $err ) {
30 die "Name $name is already in use";
31 }
32  
33 # Catch a unique constraint violation (by SQLSTATE)
34 use TryCatch;
35 try {
36 ...
37 } catch ( DBIx::Error $err where { $_->state eq "23505" } ) {
38 die "Name $name is already in use";
39 }
40  
41 # Catch any type of database error
42 use TryCatch;
43 try {
44 ...
45 } catch ( DBIx::Error $err ) {
46 die "Internal database error [SQL state ".$err->state."]:\n".$err;
47 }
48  
49 =head1 DESCRIPTION
50  
51 C<DBIx::Error> provides structured exceptions for C<DBI> errors. Each
52 five-character C<SQLSTATE> is mapped to a Perl exception class,
53 allowing exceptions to be caught using code such as
54  
55 try {
56 ...
57 } catch ( DBIx::Error::NotNullViolation $err ) {
58 ...
59 } catch ( DBIx::Error::UniqueViolation $err ) {
60 ...
61 }
62  
63 The exception stringifies to produce the full C<DBI> error message
64 (including a stack trace). The original DBI error attributes (C<err>,
65 C<errstr> and C<state>) are also provided for inspection.
66  
67 See L</"EXCEPTION CLASS HIERARCHY"> below for a list of supported
68 exception classes.
69  
70 =cut
71  
72 4 ▶use Scalar::Util qw ( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
73 4 ▶use List::MoreUtils qw ( uniq );
Subroutine BEGIN: called CC=1 SCAR=0.0
74 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 4 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
80  
81 4 extends "Throwable::Error";
82  
83 4 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 4 our $VERSION = "1.0.1";
85  
86 =head1 ATTRIBUTES
87  
88 =over
89  
90 =item C<message>
91  
92 The error message, as produced by C<DBI>.
93  
94 If C<ShowErrorStatement> was set to a true value when connecting to
95 the database, this message will include the SQL statement that caused
96 the error.
97  
98 =cut
99  
100 4 has "message" => (
101 is => "ro",
102 isa => "Str",
103 required => 1,
104 writer => "_rewrite_message",
105 );
106  
107 =item C<stack_trace>
108  
109 A stack trace, as produced using C<StackTrace::Auto>.
110  
111 =item C<err>
112  
113 The native database engine error code, as obtained from C<$DBI::err>.
114  
115 =cut
116  
117 4 has "err" => (
118 is => "ro",
119 isa => "Value",
120 required => 1,
121 );
122  
123 =item C<errstr>
124  
125 The native database engine error message, as obtained from
126 C<$DBI::errstr>.
127  
128 =cut
129  
130 4 has "errstr" => (
131 is => "ro",
132 isa => "Str",
133 required => 1,
134 );
135  
136 =item C<state>
137  
138 The state code in the standard C<SQLSTATE> five character format, as
139 obtained from C<$DBI::state>.
140  
141 =cut
142  
143 4 has "state" => (
144 is => "ro",
145 isa => "Str",
146 required => 1,
147 );
148  
149 =back
150  
151 =head1 CLASS METHODS
152  
153 =over
154  
155 =item C<< define_exception_classes ( %states ) >>
156  
157 See L</SUBCLASSING> below.
158  
159 =cut
160  
161 5 ▶sub define_exception_classes {
Subroutine define_exception_classes: called CC=3 SCAR=11.0
Pod documented
162 5 my $defining_class = shift;
163 5 my %states = @_;
164  
165 # Add "around _exception_class" modifier to return the new classes
166 5 my $meta = $defining_class->meta;
167 189 ▶ $meta->add_around_method_modifier ( "exception_class_definition", sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
168 189 my $orig = shift;
169 189 my $class = shift;
170 189 my $state = shift;
171  
172 189 ▶ if ( exists $states{$state} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $states{$state}) { } 178 11 189
173 my $exception_class = ( ( $states{$state} =~ /::/ ) ? $states{$state} :
174 178 ▶ $defining_class."::".$states{$state} );
Branch: 1 branch
BranchTrueFalseTotal
$states{$state} =~ /::/ ? : 0 178 178
175 178 return ( $exception_class, $defining_class );
176 } else {
177 11 return $class->$orig ( $state );
178 }
179 5 } );
180  
181 # Sanity check: verify that all required generic classes have been
182 # mapped (either by this class or by a superclass).
183 5 foreach my $generic_state ( uniq map { substr ( $_, 0, 2 )."000" }
184 keys %states ) {
185 157 ▶ confess "Missing mapping for generic SQLSTATE ".$generic_state
Branch: 1 branch
BranchTrueFalseTotal
unless $defining_class->exception_class_definition($generic_state) 0 157 157
186 unless $defining_class->exception_class_definition ( $generic_state );
187 }
188 }
189  
190 6 ▶sub exception_class_definition {}
Subroutine exception_class_definition: called CC=1 SCAR=0.0
191  
192 =item C<< exception_class ( $state ) >>
193  
194 Get the exception class for the specified SQLSTATE.
195  
196 =cut
197  
198 23 ▶sub exception_class {
Subroutine exception_class: called CC=5 SCAR=16.1
Pod documented
199 23 my $class = shift;
200 23 my $state = shift;
201  
202 # Determine the generic SQLSTATE
203 23 my $generic_state = substr ( $state, 0, 2 )."000";
204  
205 # Determine the exception class, its defining class, and its superclass
206 23 my $exception_class;
207 my $defining_class;
208 23 my $exception_superclass;
209 23 ▶ if ( ( $exception_class, $defining_class ) =
Branch: 2 branches
BranchTrueFalseTotal
if (() = $class->exception_class_definition($state)) { } 19 4 23
elsif (() = $class->exception_class_definition($generic_state)) { } 2 2 4
210 $class->exception_class_definition ( $state ) ) {
211 # We recognise this exact SQLSTATE
212 19 ▶ if ( $state eq $generic_state ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq $generic_state) { } 11 8 19
213 # This is a generic SQLSTATE; the superclass is the defining class
214 11 $exception_superclass = $defining_class;
215 } else {
216 # This is not a generic SQLSTATE; the superclass can be found by
217 # calling ourself recursively. (The sanity check in
218 # define_exception_classes() guarantees that this will work.)
219 8 $exception_superclass = $class->exception_class ( $generic_state );
220 }
221 } elsif ( ( $exception_class, $defining_class ) =
222 $class->exception_class_definition ( $generic_state ) ) {
223 # We don't recognise this exact SQLSTATE, but we do recognise the
224 # generic SQLSTATE
225 2 $exception_superclass = $defining_class;
226 } else {
227 # We don't even recognise the generic SQLSTATE
228 2 $exception_class = __PACKAGE__;
229 }
230  
231 # Create exception class, if applicable
232 23 ▶ if ( ! Class::MOP::does_metaclass_exist ( $exception_class ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (Class::MOP::does_metaclass_exist($exception_class)) 17 6 23
233 17 Moose::Meta::Class->create ( $exception_class,
234 superclasses => [ $exception_superclass ] )
235 ->make_immutable ( inline_constructor => 0 );
236 }
237  
238 23 return $exception_class;
239 }
240
241 =item C<< HandleError() >>
242  
243 Returns a code reference suitable for passing as the C<HandleError>
244 database connection parameter for C<DBI> (or C<DBIx::Class>, or
245 C<Catalyst::Model::DBIC::Schema>).
246  
247 =cut
248  
249 4 our $last_dbi_exception;
250  
251 2 ▶sub HandleError {
Subroutine HandleError: called CC=1 SCAR=0.0
Pod documented
252 2 my $class = shift;
253  
254 5 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
255 5 my $msg = shift;
256 5 my $h = shift;
257  
258 # Do not modify existing structured exceptions
259 5 ▶ die $msg if blessed $msg;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($msg) 0 5 5
260  
261 # Do not create a structured exception unless we have a DBI handle
262 # of some sort
263 5 ▶ die $msg unless blessed $h;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($h) 0 5 5
264  
265 # Retrieve error information from DBI handle
266 5 my $err = $h->err;
267 5 my $errstr = $h->errstr;
268 5 my $state = $h->state;
269  
270 # Determine exception class
271 5 my $exception_class = $class->exception_class ( $state );
272  
273 # Create exception
274 5 my $exception = $exception_class->new ( message => $msg,
275 err => $err,
276 errstr => $errstr,
277 state => $state );
278  
279 # Store as most recent DBI exception
280 5 $last_dbi_exception = $exception;
281  
282 # Throw exception
283 5 $exception->throw();
284 2 };
285 }
286  
287 =item C<< exception_action() >>
288  
289 Returns a code reference suitable for passing as the
290 C<exception_action> configuration parameter for C<DBIx::Class::Schema>.
291  
292 =cut
293  
294 1 ▶sub exception_action {
Subroutine exception_action: called CC=1 SCAR=0.2
Pod documented
295 1 my $class = shift;
296  
297 5 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.7
298 5 my $msg = shift;
299  
300 # Clear the stored DBI exception
301 5 my $underlying_exception = $last_dbi_exception;
302 5 undef $last_dbi_exception;
303  
304 # Do not modify existing structured exceptions
305 5 ▶ die $msg if blessed $msg;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($msg) 4 1 5
306  
307 # If we have a stored DBI exception, update its message and
308 # rethrow. We do this because DBIx::Class sometimes stringifies
309 # an exception before rethrowing it (e.g. in populate(), to add
310 # information about which populate slice caused the problem).
311 # This stringification destroys the original exception object, so
312 # we must recreate the exception with the updated message.
313 1 ▶ if ( defined $underlying_exception ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $underlying_exception) 1 0 1
314 1 $underlying_exception->_rewrite_message ( $msg );
315 1 $underlying_exception->throw();
316 }
317  
318 # Otherwise, generate a generic DBIx::Error::GeneralError exception
319 0 my $state = "S1000"; # "General Error"
320 0 my $exception_class = $class->exception_class ( $state );
321 0 $exception_class->throw ( message => $msg,
322 err => $state,
323 errstr => $msg,
324 state => $state );
325 }
326 1 }
327  
328 # Mapping from known SQLSTATE codes to exception classes. Mostly
329 # autogenerated from the PostgreSQL documentation.
330 4 my %known_sql_states = (
331 "03000" => "SqlStatementNotYetComplete",
332 "08000" => "ConnectionException",
333 "08003" => "ConnectionDoesNotExist",
334 "08006" => "ConnectionFailure",
335 "08001" => "SqlclientUnableToEstablishSqlconnection",
336 "08004" => "SqlserverRejectedEstablishmentOfSqlconnection",
337 "08007" => "TransactionResolutionUnknown",
338 "08P01" => "ProtocolViolation",
339 "09000" => "TriggeredActionException",
340 "0A000" => "FeatureNotSupported",
341 "0B000" => "InvalidTransactionInitiation",
342 "0F000" => "LocatorException",
343 "0F001" => "InvalidLocatorSpecification",
344 "0L000" => "InvalidGrantor",
345 "0LP01" => "InvalidGrantOperation",
346 "0P000" => "InvalidRoleSpecification",
347 "20000" => "CaseNotFound",
348 "21000" => "CardinalityViolation",
349 "22000" => "DataException",
350 "2202E" => "ArraySubscriptError",
351 "22021" => "CharacterNotInRepertoire",
352 "22008" => "DatetimeFieldOverflow",
353 "22012" => "DivisionByZero",
354 "22005" => "ErrorInAssignment",
355 "2200B" => "EscapeCharacterConflict",
356 "22022" => "IndicatorOverflow",
357 "22015" => "IntervalFieldOverflow",
358 "2201E" => "InvalidArgumentForLogarithm",
359 "22014" => "InvalidArgumentForNtileFunction",
360 "22016" => "InvalidArgumentForNthValueFunction",
361 "2201F" => "InvalidArgumentForPowerFunction",
362 "2201G" => "InvalidArgumentForWidthBucketFunction",
363 "22018" => "InvalidCharacterValueForCast",
364 "22007" => "InvalidDatetimeFormat",
365 "22019" => "InvalidEscapeCharacter",
366 "2200D" => "InvalidEscapeOctet",
367 "22025" => "InvalidEscapeSequence",
368 "22P06" => "NonstandardUseOfEscapeCharacter",
369 "22010" => "InvalidIndicatorParameterValue",
370 "22023" => "InvalidParameterValue",
371 "2201B" => "InvalidRegularExpression",
372 "2201W" => "InvalidRowCountInLimitClause",
373 "2201X" => "InvalidRowCountInResultOffsetClause",
374 "22009" => "InvalidTimeZoneDisplacementValue",
375 "2200C" => "InvalidUseOfEscapeCharacter",
376 "2200G" => "MostSpecificTypeMismatch",
377 "22004" => "NullValueNotAllowed",
378 "22002" => "NullValueNoIndicatorParameter",
379 "22003" => "NumericValueOutOfRange",
380 "22026" => "StringDataLengthMismatch",
381 "22001" => "StringDataRightTruncation",
382 "22011" => "SubstringError",
383 "22027" => "TrimError",
384 "22024" => "UnterminatedCString",
385 "2200F" => "ZeroLengthCharacterString",
386 "22P01" => "FloatingPointException",
387 "22P02" => "InvalidTextRepresentation",
388 "22P03" => "InvalidBinaryRepresentation",
389 "22P04" => "BadCopyFileFormat",
390 "22P05" => "UntranslatableCharacter",
391 "2200L" => "NotAnXmlDocument",
392 "2200M" => "InvalidXmlDocument",
393 "2200N" => "InvalidXmlContent",
394 "2200S" => "InvalidXmlComment",
395 "2200T" => "InvalidXmlProcessingInstruction",
396 "23000" => "IntegrityConstraintViolation",
397 "23001" => "RestrictViolation",
398 "23502" => "NotNullViolation",
399 "23503" => "ForeignKeyViolation",
400 "23505" => "UniqueViolation",
401 "23514" => "CheckViolation",
402 "23P01" => "ExclusionViolation",
403 "24000" => "InvalidCursorState",
404 "25000" => "InvalidTransactionState",
405 "25001" => "ActiveSqlTransaction",
406 "25002" => "BranchTransactionAlreadyActive",
407 "25008" => "HeldCursorRequiresSameIsolationLevel",
408 "25003" => "InappropriateAccessModeForBranchTransaction",
409 "25004" => "InappropriateIsolationLevelForBranchTransaction",
410 "25005" => "NoActiveSqlTransactionForBranchTransaction",
411 "25006" => "ReadOnlySqlTransaction",
412 "25007" => "SchemaAndDataStatementMixingNotSupported",
413 "25P01" => "NoActiveSqlTransaction",
414 "25P02" => "InFailedSqlTransaction",
415 "26000" => "InvalidSqlStatementName",
416 "27000" => "TriggeredDataChangeViolation",
417 "28000" => "InvalidAuthorizationSpecification",
418 "28P01" => "InvalidPassword",
419 "2B000" => "DependentPrivilegeDescriptorsStillExist",
420 "2BP01" => "DependentObjectsStillExist",
421 "2D000" => "InvalidTransactionTermination",
422 "2F000" => "SqlRoutineException",
423 "34000" => "InvalidCursorName",
424 "38000" => "ExternalRoutineException",
425 "39000" => "ExternalRoutineInvocationException",
426 "3B000" => "SavepointException",
427 "3B001" => "InvalidSavepointSpecification",
428 "3D000" => "InvalidCatalogName",
429 "3F000" => "InvalidSchemaName",
430 "40000" => "TransactionRollback",
431 "40002" => "TransactionIntegrityConstraintViolation",
432 "40001" => "SerializationFailure",
433 "40003" => "StatementCompletionUnknown",
434 "40P01" => "DeadlockDetected",
435 "42000" => "SyntaxErrorOrAccessRuleViolation",
436 "42601" => "SyntaxError",
437 "42501" => "InsufficientPrivilege",
438 "42846" => "CannotCoerce",
439 "42803" => "GroupingError",
440 "42P20" => "WindowingError",
441 "42P19" => "InvalidRecursion",
442 "42830" => "InvalidForeignKey",
443 "42602" => "InvalidName",
444 "42622" => "NameTooLong",
445 "42939" => "ReservedName",
446 "42804" => "DatatypeMismatch",
447 "42P18" => "IndeterminateDatatype",
448 "42P21" => "CollationMismatch",
449 "42P22" => "IndeterminateCollation",
450 "42809" => "WrongObjectType",
451 "42703" => "UndefinedColumn",
452 "42883" => "UndefinedFunction",
453 "42P01" => "UndefinedTable",
454 "42P02" => "UndefinedParameter",
455 "42704" => "UndefinedObject",
456 "42701" => "DuplicateColumn",
457 "42P03" => "DuplicateCursor",
458 "42P04" => "DuplicateDatabase",
459 "42723" => "DuplicateFunction",
460 "42P05" => "DuplicatePreparedStatement",
461 "42P06" => "DuplicateSchema",
462 "42P07" => "DuplicateTable",
463 "42712" => "DuplicateAlias",
464 "42710" => "DuplicateObject",
465 "42702" => "AmbiguousColumn",
466 "42725" => "AmbiguousFunction",
467 "42P08" => "AmbiguousParameter",
468 "42P09" => "AmbiguousAlias",
469 "42P10" => "InvalidColumnReference",
470 "42611" => "InvalidColumnDefinition",
471 "42P11" => "InvalidCursorDefinition",
472 "42P12" => "InvalidDatabaseDefinition",
473 "42P13" => "InvalidFunctionDefinition",
474 "42P14" => "InvalidPreparedStatementDefinition",
475 "42P15" => "InvalidSchemaDefinition",
476 "42P16" => "InvalidTableDefinition",
477 "42P17" => "InvalidObjectDefinition",
478 "44000" => "WithCheckOptionViolation",
479 "53000" => "InsufficientResources",
480 "53100" => "DiskFull",
481 "53200" => "OutOfMemory",
482 "53300" => "TooManyConnections",
483 "54000" => "ProgramLimitExceeded",
484 "54001" => "StatementTooComplex",
485 "54011" => "TooManyColumns",
486 "54023" => "TooManyArguments",
487 "55000" => "ObjectNotInPrerequisiteState",
488 "55006" => "ObjectInUse",
489 "55P02" => "CantChangeRuntimeParam",
490 "55P03" => "LockNotAvailable",
491 "57000" => "OperatorIntervention",
492 "57014" => "QueryCanceled",
493 "57P01" => "AdminShutdown",
494 "57P02" => "CrashShutdown",
495 "57P03" => "CannotConnectNow",
496 "57P04" => "DatabaseDropped",
497 "58000" => "SystemError", # added manually
498 "58030" => "IoError",
499 "58P01" => "UndefinedFile",
500 "58P02" => "DuplicateFile",
501 "F0000" => "ConfigFileError",
502 "F0001" => "LockFileExists",
503 "HV000" => "FdwError",
504 "HV005" => "FdwColumnNameNotFound",
505 "HV002" => "FdwDynamicParameterValueNeeded",
506 "HV010" => "FdwFunctionSequenceError",
507 "HV021" => "FdwInconsistentDescriptorInformation",
508 "HV024" => "FdwInvalidAttributeValue",
509 "HV007" => "FdwInvalidColumnName",
510 "HV008" => "FdwInvalidColumnNumber",
511 "HV004" => "FdwInvalidDataType",
512 "HV006" => "FdwInvalidDataTypeDescriptors",
513 "HV091" => "FdwInvalidDescriptorFieldIdentifier",
514 "HV00B" => "FdwInvalidHandle",
515 "HV00C" => "FdwInvalidOptionIndex",
516 "HV00D" => "FdwInvalidOptionName",
517 "HV090" => "FdwInvalidStringLengthOrBufferLength",
518 "HV00A" => "FdwInvalidStringFormat",
519 "HV009" => "FdwInvalidUseOfNullPointer",
520 "HV014" => "FdwTooManyHandles",
521 "HV001" => "FdwOutOfMemory",
522 "HV00P" => "FdwNoSchemas",
523 "HV00J" => "FdwOptionNameNotFound",
524 "HV00K" => "FdwReplyHandle",
525 "HV00Q" => "FdwSchemaNotFound",
526 "HV00R" => "FdwTableNotFound",
527 "HV00L" => "FdwUnableToCreateExecution",
528 "HV00M" => "FdwUnableToCreateReply",
529 "HV00N" => "FdwUnableToEstablishConnection",
530 "P0000" => "PlpgsqlError",
531 "P0001" => "RaiseException",
532 "P0002" => "NoDataFound",
533 "P0003" => "TooManyRows",
534 "S1000" => "GeneralError", # added manually
535 "XX000" => "InternalError",
536 "XX001" => "DataCorrupted",
537 "XX002" => "IndexCorrupted",
538 );
539  
540 4 __PACKAGE__->define_exception_classes ( %known_sql_states );
541  
542 # StackTrace::Auto prevents inlined constructors
543 4 __PACKAGE__->meta->make_immutable ( inline_constructor => 0 );
544  
545 =back
546  
547 =head1 USAGE PATTERNS
548  
549 =head2 Using plain DBI
550  
551 use DBI;
552 use DBIx::Error;
553 use TryCatch;
554  
555 my $db = DBI->connect ( $dsn, $user, $password,
556 { HandleError => DBIx::Error->HandleError,
557 ShowErrorStatement => 1 } );
558  
559 my $sth = $db->prepare ( "INSERT INTO people VALUES ( ? )" );
560 try {
561 $sth->execute ( $name );
562 } catch ( DBIx::Error::UniqueViolation $err ) {
563 die "$name is already present in the database";
564 } catch ( DBIx::Error::IntegrityConstraintViolation $err ) {
565 die "$name is not allowed";
566 }
567  
568 =head2 Using DBIx::Class
569  
570 package MyDB::Schema;
571 use base qw ( DBIx::Class::Schema );
572 use DBIx::Error;
573 __PACKAGE__->exception_action ( DBIx::Error->exception_action );
574 __PACKAGE__->load_namespaces();
575  
576 use MyDB::Schema;
577 use TryCatch;
578 my $db = MyDB::Schema->connect ( {
579 dsn => $dsn,
580 user => $user,
581 password => $password,
582 HandleError => DBIx::Error->HandleError,
583 ShowErrorStatment => 1,
584 unsafe => 1,
585 } );
586 try {
587 $db->resultset ( "People" )->create ( { name => $name } );
588 } catch ( DBIx::Error::UniqueViolation $err ) {
589 die "$name is already present in the database";
590 } catch ( DBIx::Error::IntegrityConstraintViolation $err ) {
591 die "$name is not allowed";
592 }
593  
594 =head2 Using Catalyst::Model::DBIC::Schema
595  
596 package MyDB::Schema;
597 use base qw ( DBIx::Class::Schema );
598 use DBIx::Error;
599 __PACKAGE__->exception_action ( DBIx::Error->exception_action );
600 __PACKAGE__->load_namespaces();
601  
602 package MyApp::Model::MyDB;
603 use base qw ( Catalyst::Model::DBIC::Schema );
604 use MyDB::Schema;
605 use DBIx::Error;
606 __PACKAGE__->config (
607 schema_class => "MyDB::Schema",
608 connect_info => {
609 dsn => $dsn,
610 user => $user,
611 password => $password,
612 HandleError => DBIx::Error->HandleError,
613 ShowErrorStatment => 1,
614 unsafe => 1,
615 },
616 );
617  
618 =head1 LIMITATIONS
619  
620 =head2 Database engines
621  
622 B<C<DBIx::Error> can produce an exception of the correct subclass only
623 if the underlying database engine supports SQLSTATE.> (If the
624 underlying driver does not support SQLSTATE then all exceptions will
625 have the class C<DBIx::Error> and the only way to determine what
626 actually caused the error will be to examine the text of the error
627 message.)
628  
629 C<DBIx::Error> is known to work reliably with PostgreSQL databases.
630  
631 =head2 Bulk operations
632  
633 Bulk operations using C<< DBI->execute_array() >> may not work as
634 expected. The underlying C<DBI> code will not raise an exception
635 until the entire bulk operation has completed, and the exception will
636 represent the most recent failure at the time the operation completes.
637  
638 In most (but not all) cases, this will result in a
639 C<DBIx::Error::InFailedSqlTransaction> exception, since the
640 transaction will already have been aborted. To raise an exception
641 corresponding to the original error (the one which caused the
642 transaction to abort), the caller would have to parse the
643 C<ArrayTupleStatus> array and use C<< DBI->set_err() >> to regenerate
644 the exception corresponding to the appropriate row.
645  
646 This limitation also applies to operations built on top of
647 C<< DBI->execute_array() >>, such as C<< DBIx::Class::Schema->populate() >>.
648  
649 As a general rule: assume that the only sensible exception class that
650 can be caught from any bulk operation is the root class C<DBIx::Error>:
651  
652 try {
653 $sth->execute_array ( @args );
654 } catch ( DBIx::Error $err ) {
655 # Could be any type of DBI error
656 }
657  
658 =begin comment
659  
660 This limitation in DBI can be worked around using the following patch:
661  
662 --- DBI.pm.orig 2012-08-09 22:30:15.209056169 +0100
663 +++ DBI.pm 2012-08-09 22:30:23.362954232 +0100
664 @@ -1986,6 +1986,5 @@
665 $err_count++;
666 push @$tuple_status, [ $sth->err, $sth->errstr, $sth->state ];
667 - # XXX drivers implementing execute_for_fetch could opt to "last;" here
668 - # if they know the error code means no further executes will work.
669 + last;
670 }
671 }
672  
673 =end comment
674  
675 =head1 CAVEATS
676  
677 =head2 C<< DBIx::Class::Schema->txn_do() >>
678  
679 Any plain errors (i.e. C<< die "some_message"; >> statements) within a
680 C<txn_do()> block will be converted into C<DBIx::Error::GeneralError>
681 exceptions:
682  
683 try {
684 $db->txn_do ( sub {
685 die "foo";
686 } );
687 } catch ( $err ) {
688 print "Caught ".( ref $err )." exception with message: ".$err;
689 }
690 # will print "Caught DBIx::Error::GeneralError exception with message: foo"
691  
692 To avoid this behaviour, use exception objects instead of plain C<die>:
693  
694 try {
695 $db->txn_do ( sub {
696 My::Error->throw ( "foo" );
697 } );
698 } catch ( $err ) {
699 ...
700 }
701  
702 =head1 SUBCLASSING
703  
704 Applications can define custom SQLSTATE codes to represent
705 application-specific database errors. For example, using PostgreSQL's
706 PL/pgSQL:
707  
708 CREATE FUNCTION test_custom_exception() RETURNS void AS $$
709 BEGIN
710 RAISE EXCEPTION 'Something bad happened'
711 USING ERRCODE = 'MY001';
712 END;
713 $$ LANGUAGE plpgsql VOLATILE;
714  
715 These custom SQLSTATE codes can be mapped to Perl exception classes by
716 subclassing C<DBIx::Error> and defining the appropriate mappings using
717 the C<define_exception_classes()> class method. For example:
718  
719 package MyApplication::Error::DBI;
720  
721 use Moose;
722 extends "DBIx::Error";
723  
724 __PACKAGE__->define_exception_classes (
725 "MY000" => "General",
726 "MY001" => "SomethingBadHappened"
727 );
728  
729 __PACKAGE__->meta->make_immutable ( inline_constructor => 0 );
730  
731 1;
732  
733 The resulting exception classes will be subclasses of the package
734 which calls C<define_exception_classes()>. In the above example, the
735 exception classes will be:
736  
737 C<MyApplication::Error::DBI::General>
738 C<MyApplication::Error::DBI::SomethingBadHappened>
739  
740 The exceptions can be caught in the usual way:
741  
742 use TryCatch;
743 try {
744 ...
745 } catch ( MyApplication::Error::DBI::SomethingBadHappened $err ) {
746 ...
747 } catch ( DBIx::Error::UniqueViolation $err ) {
748 ...
749 }
750  
751 Mappings for the generic SQLSTATE codes (ending in "000") act as
752 superclasses for the more specific SQLSTATE codes (ending in anything
753 other than "000"). You must define mappings for the generic SQLSTATE
754 codes corresponding to any application-specific SQLSTATE codes.
755  
756 By default, the exception classes will be prefixed with the name of
757 the package which calls C<define_exception_classes()>. You can
758 override this by specifying full class names for the exception
759 subclasses, e.g.
760  
761 __PACKAGE__->define_exception_classes (
762 "QA000" => "MyApp::Error::General"
763 );
764  
765 =head1 EXCEPTION CLASS HIERARCHY
766  
767 =over
768  
769 =item C<DBIx::Error>
770  
771 =over
772  
773 =cut
774  
775 # This method is used to generate the following section of
776 # documentation.
777 #
778 0 ▶sub _build_pod {
Subroutine _build_pod: not called CC=5 SCAR=34.0
779 0 my $count = 0;
780 0 foreach my $state ( sort keys %known_sql_states ) {
781 0 my $exception_class = __PACKAGE__."::".$known_sql_states{$state};
782 0 ▶ print "=back\n\n" if $state =~ /000$/ && $count++;
Branch: 1 branch
BranchTrueFalseTotal
if $state =~ /000$/ and $count++ 0 0 0
Condition0%0/3
$state =~ /000$/ and $count++
!ll&&!rl&&r
000
MC/DC0%0/2
$state =~ /000$/ and $count++
$state =~ /000$/ $count++
Truth table0%0/3
A and B
A= $state =~ /000$/B= $count++
ABresult
0X0
100
111
783 0 print "=item C<".$exception_class."> (C<".$state.">)\n\n";
784 0 ▶ print "=over\n\n" if $state =~ /000$/;
Branch: 1 branch
BranchTrueFalseTotal
if $state =~ /000$/ 0 0 0
785 }
786 0 print "=cut\n";
787 }
788  
789 #
790 # BEGIN AUTOGENERATED DOCUMENTATION
791 #
792  
793 =item C<DBIx::Error::SqlStatementNotYetComplete> (C<03000>)
794  
795 =over
796  
797 =back
798  
799 =item C<DBIx::Error::ConnectionException> (C<08000>)
800  
801 =over
802  
803 =item C<DBIx::Error::SqlclientUnableToEstablishSqlconnection> (C<08001>)
804  
805 =item C<DBIx::Error::ConnectionDoesNotExist> (C<08003>)
806  
807 =item C<DBIx::Error::SqlserverRejectedEstablishmentOfSqlconnection> (C<08004>)
808  
809 =item C<DBIx::Error::ConnectionFailure> (C<08006>)
810  
811 =item C<DBIx::Error::TransactionResolutionUnknown> (C<08007>)
812  
813 =item C<DBIx::Error::ProtocolViolation> (C<08P01>)
814  
815 =back
816  
817 =item C<DBIx::Error::TriggeredActionException> (C<09000>)
818  
819 =over
820  
821 =back
822  
823 =item C<DBIx::Error::FeatureNotSupported> (C<0A000>)
824  
825 =over
826  
827 =back
828  
829 =item C<DBIx::Error::InvalidTransactionInitiation> (C<0B000>)
830  
831 =over
832  
833 =back
834  
835 =item C<DBIx::Error::LocatorException> (C<0F000>)
836  
837 =over
838  
839 =item C<DBIx::Error::InvalidLocatorSpecification> (C<0F001>)
840  
841 =back
842  
843 =item C<DBIx::Error::InvalidGrantor> (C<0L000>)
844  
845 =over
846  
847 =item C<DBIx::Error::InvalidGrantOperation> (C<0LP01>)
848  
849 =back
850  
851 =item C<DBIx::Error::InvalidRoleSpecification> (C<0P000>)
852  
853 =over
854  
855 =back
856  
857 =item C<DBIx::Error::CaseNotFound> (C<20000>)
858  
859 =over
860  
861 =back
862  
863 =item C<DBIx::Error::CardinalityViolation> (C<21000>)
864  
865 =over
866  
867 =back
868  
869 =item C<DBIx::Error::DataException> (C<22000>)
870  
871 =over
872  
873 =item C<DBIx::Error::StringDataRightTruncation> (C<22001>)
874  
875 =item C<DBIx::Error::NullValueNoIndicatorParameter> (C<22002>)
876  
877 =item C<DBIx::Error::NumericValueOutOfRange> (C<22003>)
878  
879 =item C<DBIx::Error::NullValueNotAllowed> (C<22004>)
880  
881 =item C<DBIx::Error::ErrorInAssignment> (C<22005>)
882  
883 =item C<DBIx::Error::InvalidDatetimeFormat> (C<22007>)
884  
885 =item C<DBIx::Error::DatetimeFieldOverflow> (C<22008>)
886  
887 =item C<DBIx::Error::InvalidTimeZoneDisplacementValue> (C<22009>)
888  
889 =item C<DBIx::Error::EscapeCharacterConflict> (C<2200B>)
890  
891 =item C<DBIx::Error::InvalidUseOfEscapeCharacter> (C<2200C>)
892  
893 =item C<DBIx::Error::InvalidEscapeOctet> (C<2200D>)
894  
895 =item C<DBIx::Error::ZeroLengthCharacterString> (C<2200F>)
896  
897 =item C<DBIx::Error::MostSpecificTypeMismatch> (C<2200G>)
898  
899 =item C<DBIx::Error::NotAnXmlDocument> (C<2200L>)
900  
901 =item C<DBIx::Error::InvalidXmlDocument> (C<2200M>)
902  
903 =item C<DBIx::Error::InvalidXmlContent> (C<2200N>)
904  
905 =item C<DBIx::Error::InvalidXmlComment> (C<2200S>)
906  
907 =item C<DBIx::Error::InvalidXmlProcessingInstruction> (C<2200T>)
908  
909 =item C<DBIx::Error::InvalidIndicatorParameterValue> (C<22010>)
910  
911 =item C<DBIx::Error::SubstringError> (C<22011>)
912  
913 =item C<DBIx::Error::DivisionByZero> (C<22012>)
914  
915 =item C<DBIx::Error::InvalidArgumentForNtileFunction> (C<22014>)
916  
917 =item C<DBIx::Error::IntervalFieldOverflow> (C<22015>)
918  
919 =item C<DBIx::Error::InvalidArgumentForNthValueFunction> (C<22016>)
920  
921 =item C<DBIx::Error::InvalidCharacterValueForCast> (C<22018>)
922  
923 =item C<DBIx::Error::InvalidEscapeCharacter> (C<22019>)
924  
925 =item C<DBIx::Error::InvalidRegularExpression> (C<2201B>)
926  
927 =item C<DBIx::Error::InvalidArgumentForLogarithm> (C<2201E>)
928  
929 =item C<DBIx::Error::InvalidArgumentForPowerFunction> (C<2201F>)
930  
931 =item C<DBIx::Error::InvalidArgumentForWidthBucketFunction> (C<2201G>)
932  
933 =item C<DBIx::Error::InvalidRowCountInLimitClause> (C<2201W>)
934  
935 =item C<DBIx::Error::InvalidRowCountInResultOffsetClause> (C<2201X>)
936  
937 =item C<DBIx::Error::CharacterNotInRepertoire> (C<22021>)
938  
939 =item C<DBIx::Error::IndicatorOverflow> (C<22022>)
940  
941 =item C<DBIx::Error::InvalidParameterValue> (C<22023>)
942  
943 =item C<DBIx::Error::UnterminatedCString> (C<22024>)
944  
945 =item C<DBIx::Error::InvalidEscapeSequence> (C<22025>)
946  
947 =item C<DBIx::Error::StringDataLengthMismatch> (C<22026>)
948  
949 =item C<DBIx::Error::TrimError> (C<22027>)
950  
951 =item C<DBIx::Error::ArraySubscriptError> (C<2202E>)
952  
953 =item C<DBIx::Error::FloatingPointException> (C<22P01>)
954  
955 =item C<DBIx::Error::InvalidTextRepresentation> (C<22P02>)
956  
957 =item C<DBIx::Error::InvalidBinaryRepresentation> (C<22P03>)
958  
959 =item C<DBIx::Error::BadCopyFileFormat> (C<22P04>)
960  
961 =item C<DBIx::Error::UntranslatableCharacter> (C<22P05>)
962  
963 =item C<DBIx::Error::NonstandardUseOfEscapeCharacter> (C<22P06>)
964  
965 =back
966  
967 =item C<DBIx::Error::IntegrityConstraintViolation> (C<23000>)
968  
969 =over
970  
971 =item C<DBIx::Error::RestrictViolation> (C<23001>)
972  
973 =item C<DBIx::Error::NotNullViolation> (C<23502>)
974  
975 =item C<DBIx::Error::ForeignKeyViolation> (C<23503>)
976  
977 =item C<DBIx::Error::UniqueViolation> (C<23505>)
978  
979 =item C<DBIx::Error::CheckViolation> (C<23514>)
980  
981 =item C<DBIx::Error::ExclusionViolation> (C<23P01>)
982  
983 =back
984  
985 =item C<DBIx::Error::InvalidCursorState> (C<24000>)
986  
987 =over
988  
989 =back
990  
991 =item C<DBIx::Error::InvalidTransactionState> (C<25000>)
992  
993 =over
994  
995 =item C<DBIx::Error::ActiveSqlTransaction> (C<25001>)
996  
997 =item C<DBIx::Error::BranchTransactionAlreadyActive> (C<25002>)
998  
999 =item C<DBIx::Error::InappropriateAccessModeForBranchTransaction> (C<25003>)
1000  
1001 =item C<DBIx::Error::InappropriateIsolationLevelForBranchTransaction> (C<25004>)
1002  
1003 =item C<DBIx::Error::NoActiveSqlTransactionForBranchTransaction> (C<25005>)
1004  
1005 =item C<DBIx::Error::ReadOnlySqlTransaction> (C<25006>)
1006  
1007 =item C<DBIx::Error::SchemaAndDataStatementMixingNotSupported> (C<25007>)
1008  
1009 =item C<DBIx::Error::HeldCursorRequiresSameIsolationLevel> (C<25008>)
1010  
1011 =item C<DBIx::Error::NoActiveSqlTransaction> (C<25P01>)
1012  
1013 =item C<DBIx::Error::InFailedSqlTransaction> (C<25P02>)
1014  
1015 =back
1016  
1017 =item C<DBIx::Error::InvalidSqlStatementName> (C<26000>)
1018  
1019 =over
1020  
1021 =back
1022  
1023 =item C<DBIx::Error::TriggeredDataChangeViolation> (C<27000>)
1024  
1025 =over
1026  
1027 =back
1028  
1029 =item C<DBIx::Error::InvalidAuthorizationSpecification> (C<28000>)
1030  
1031 =over
1032  
1033 =item C<DBIx::Error::InvalidPassword> (C<28P01>)
1034  
1035 =back
1036  
1037 =item C<DBIx::Error::DependentPrivilegeDescriptorsStillExist> (C<2B000>)
1038  
1039 =over
1040  
1041 =item C<DBIx::Error::DependentObjectsStillExist> (C<2BP01>)
1042  
1043 =back
1044  
1045 =item C<DBIx::Error::InvalidTransactionTermination> (C<2D000>)
1046  
1047 =over
1048  
1049 =back
1050  
1051 =item C<DBIx::Error::SqlRoutineException> (C<2F000>)
1052  
1053 =over
1054  
1055 =back
1056  
1057 =item C<DBIx::Error::InvalidCursorName> (C<34000>)
1058  
1059 =over
1060  
1061 =back
1062  
1063 =item C<DBIx::Error::ExternalRoutineException> (C<38000>)
1064  
1065 =over
1066  
1067 =back
1068  
1069 =item C<DBIx::Error::ExternalRoutineInvocationException> (C<39000>)
1070  
1071 =over
1072  
1073 =back
1074  
1075 =item C<DBIx::Error::SavepointException> (C<3B000>)
1076  
1077 =over
1078  
1079 =item C<DBIx::Error::InvalidSavepointSpecification> (C<3B001>)
1080  
1081 =back
1082  
1083 =item C<DBIx::Error::InvalidCatalogName> (C<3D000>)
1084  
1085 =over
1086  
1087 =back
1088  
1089 =item C<DBIx::Error::InvalidSchemaName> (C<3F000>)
1090  
1091 =over
1092  
1093 =back
1094  
1095 =item C<DBIx::Error::TransactionRollback> (C<40000>)
1096  
1097 =over
1098  
1099 =item C<DBIx::Error::SerializationFailure> (C<40001>)
1100  
1101 =item C<DBIx::Error::TransactionIntegrityConstraintViolation> (C<40002>)
1102  
1103 =item C<DBIx::Error::StatementCompletionUnknown> (C<40003>)
1104  
1105 =item C<DBIx::Error::DeadlockDetected> (C<40P01>)
1106  
1107 =back
1108  
1109 =item C<DBIx::Error::SyntaxErrorOrAccessRuleViolation> (C<42000>)
1110  
1111 =over
1112  
1113 =item C<DBIx::Error::InsufficientPrivilege> (C<42501>)
1114  
1115 =item C<DBIx::Error::SyntaxError> (C<42601>)
1116  
1117 =item C<DBIx::Error::InvalidName> (C<42602>)
1118  
1119 =item C<DBIx::Error::InvalidColumnDefinition> (C<42611>)
1120  
1121 =item C<DBIx::Error::NameTooLong> (C<42622>)
1122  
1123 =item C<DBIx::Error::DuplicateColumn> (C<42701>)
1124  
1125 =item C<DBIx::Error::AmbiguousColumn> (C<42702>)
1126  
1127 =item C<DBIx::Error::UndefinedColumn> (C<42703>)
1128  
1129 =item C<DBIx::Error::UndefinedObject> (C<42704>)
1130  
1131 =item C<DBIx::Error::DuplicateObject> (C<42710>)
1132  
1133 =item C<DBIx::Error::DuplicateAlias> (C<42712>)
1134  
1135 =item C<DBIx::Error::DuplicateFunction> (C<42723>)
1136  
1137 =item C<DBIx::Error::AmbiguousFunction> (C<42725>)
1138  
1139 =item C<DBIx::Error::GroupingError> (C<42803>)
1140  
1141 =item C<DBIx::Error::DatatypeMismatch> (C<42804>)
1142  
1143 =item C<DBIx::Error::WrongObjectType> (C<42809>)
1144  
1145 =item C<DBIx::Error::InvalidForeignKey> (C<42830>)
1146  
1147 =item C<DBIx::Error::CannotCoerce> (C<42846>)
1148  
1149 =item C<DBIx::Error::UndefinedFunction> (C<42883>)
1150  
1151 =item C<DBIx::Error::ReservedName> (C<42939>)
1152  
1153 =item C<DBIx::Error::UndefinedTable> (C<42P01>)
1154  
1155 =item C<DBIx::Error::UndefinedParameter> (C<42P02>)
1156  
1157 =item C<DBIx::Error::DuplicateCursor> (C<42P03>)
1158  
1159 =item C<DBIx::Error::DuplicateDatabase> (C<42P04>)
1160  
1161 =item C<DBIx::Error::DuplicatePreparedStatement> (C<42P05>)
1162  
1163 =item C<DBIx::Error::DuplicateSchema> (C<42P06>)
1164  
1165 =item C<DBIx::Error::DuplicateTable> (C<42P07>)
1166  
1167 =item C<DBIx::Error::AmbiguousParameter> (C<42P08>)
1168  
1169 =item C<DBIx::Error::AmbiguousAlias> (C<42P09>)
1170  
1171 =item C<DBIx::Error::InvalidColumnReference> (C<42P10>)
1172  
1173 =item C<DBIx::Error::InvalidCursorDefinition> (C<42P11>)
1174  
1175 =item C<DBIx::Error::InvalidDatabaseDefinition> (C<42P12>)
1176  
1177 =item C<DBIx::Error::InvalidFunctionDefinition> (C<42P13>)
1178  
1179 =item C<DBIx::Error::InvalidPreparedStatementDefinition> (C<42P14>)
1180  
1181 =item C<DBIx::Error::InvalidSchemaDefinition> (C<42P15>)
1182  
1183 =item C<DBIx::Error::InvalidTableDefinition> (C<42P16>)
1184  
1185 =item C<DBIx::Error::InvalidObjectDefinition> (C<42P17>)
1186  
1187 =item C<DBIx::Error::IndeterminateDatatype> (C<42P18>)
1188  
1189 =item C<DBIx::Error::InvalidRecursion> (C<42P19>)
1190  
1191 =item C<DBIx::Error::WindowingError> (C<42P20>)
1192  
1193 =item C<DBIx::Error::CollationMismatch> (C<42P21>)
1194  
1195 =item C<DBIx::Error::IndeterminateCollation> (C<42P22>)
1196  
1197 =back
1198  
1199 =item C<DBIx::Error::WithCheckOptionViolation> (C<44000>)
1200  
1201 =over
1202  
1203 =back
1204  
1205 =item C<DBIx::Error::InsufficientResources> (C<53000>)
1206  
1207 =over
1208  
1209 =item C<DBIx::Error::DiskFull> (C<53100>)
1210  
1211 =item C<DBIx::Error::OutOfMemory> (C<53200>)
1212  
1213 =item C<DBIx::Error::TooManyConnections> (C<53300>)
1214  
1215 =back
1216  
1217 =item C<DBIx::Error::ProgramLimitExceeded> (C<54000>)
1218  
1219 =over
1220  
1221 =item C<DBIx::Error::StatementTooComplex> (C<54001>)
1222  
1223 =item C<DBIx::Error::TooManyColumns> (C<54011>)
1224  
1225 =item C<DBIx::Error::TooManyArguments> (C<54023>)
1226  
1227 =back
1228  
1229 =item C<DBIx::Error::ObjectNotInPrerequisiteState> (C<55000>)
1230  
1231 =over
1232  
1233 =item C<DBIx::Error::ObjectInUse> (C<55006>)
1234  
1235 =item C<DBIx::Error::CantChangeRuntimeParam> (C<55P02>)
1236  
1237 =item C<DBIx::Error::LockNotAvailable> (C<55P03>)
1238  
1239 =back
1240  
1241 =item C<DBIx::Error::OperatorIntervention> (C<57000>)
1242  
1243 =over
1244  
1245 =item C<DBIx::Error::QueryCanceled> (C<57014>)
1246  
1247 =item C<DBIx::Error::AdminShutdown> (C<57P01>)
1248  
1249 =item C<DBIx::Error::CrashShutdown> (C<57P02>)
1250  
1251 =item C<DBIx::Error::CannotConnectNow> (C<57P03>)
1252  
1253 =item C<DBIx::Error::DatabaseDropped> (C<57P04>)
1254  
1255 =back
1256  
1257 =item C<DBIx::Error::SystemError> (C<58000>)
1258  
1259 =over
1260  
1261 =item C<DBIx::Error::IoError> (C<58030>)
1262  
1263 =item C<DBIx::Error::UndefinedFile> (C<58P01>)
1264  
1265 =item C<DBIx::Error::DuplicateFile> (C<58P02>)
1266  
1267 =back
1268  
1269 =item C<DBIx::Error::ConfigFileError> (C<F0000>)
1270  
1271 =over
1272  
1273 =item C<DBIx::Error::LockFileExists> (C<F0001>)
1274  
1275 =back
1276  
1277 =item C<DBIx::Error::FdwError> (C<HV000>)
1278  
1279 =over
1280  
1281 =item C<DBIx::Error::FdwOutOfMemory> (C<HV001>)
1282  
1283 =item C<DBIx::Error::FdwDynamicParameterValueNeeded> (C<HV002>)
1284  
1285 =item C<DBIx::Error::FdwInvalidDataType> (C<HV004>)
1286  
1287 =item C<DBIx::Error::FdwColumnNameNotFound> (C<HV005>)
1288  
1289 =item C<DBIx::Error::FdwInvalidDataTypeDescriptors> (C<HV006>)
1290  
1291 =item C<DBIx::Error::FdwInvalidColumnName> (C<HV007>)
1292  
1293 =item C<DBIx::Error::FdwInvalidColumnNumber> (C<HV008>)
1294  
1295 =item C<DBIx::Error::FdwInvalidUseOfNullPointer> (C<HV009>)
1296  
1297 =item C<DBIx::Error::FdwInvalidStringFormat> (C<HV00A>)
1298  
1299 =item C<DBIx::Error::FdwInvalidHandle> (C<HV00B>)
1300  
1301 =item C<DBIx::Error::FdwInvalidOptionIndex> (C<HV00C>)
1302  
1303 =item C<DBIx::Error::FdwInvalidOptionName> (C<HV00D>)
1304  
1305 =item C<DBIx::Error::FdwOptionNameNotFound> (C<HV00J>)
1306  
1307 =item C<DBIx::Error::FdwReplyHandle> (C<HV00K>)
1308  
1309 =item C<DBIx::Error::FdwUnableToCreateExecution> (C<HV00L>)
1310  
1311 =item C<DBIx::Error::FdwUnableToCreateReply> (C<HV00M>)
1312  
1313 =item C<DBIx::Error::FdwUnableToEstablishConnection> (C<HV00N>)
1314  
1315 =item C<DBIx::Error::FdwNoSchemas> (C<HV00P>)
1316  
1317 =item C<DBIx::Error::FdwSchemaNotFound> (C<HV00Q>)
1318  
1319 =item C<DBIx::Error::FdwTableNotFound> (C<HV00R>)
1320  
1321 =item C<DBIx::Error::FdwFunctionSequenceError> (C<HV010>)
1322  
1323 =item C<DBIx::Error::FdwTooManyHandles> (C<HV014>)
1324  
1325 =item C<DBIx::Error::FdwInconsistentDescriptorInformation> (C<HV021>)
1326  
1327 =item C<DBIx::Error::FdwInvalidAttributeValue> (C<HV024>)
1328  
1329 =item C<DBIx::Error::FdwInvalidStringLengthOrBufferLength> (C<HV090>)
1330  
1331 =item C<DBIx::Error::FdwInvalidDescriptorFieldIdentifier> (C<HV091>)
1332  
1333 =back
1334  
1335 =item C<DBIx::Error::PlpgsqlError> (C<P0000>)
1336  
1337 =over
1338  
1339 =item C<DBIx::Error::RaiseException> (C<P0001>)
1340  
1341 =item C<DBIx::Error::NoDataFound> (C<P0002>)
1342  
1343 =item C<DBIx::Error::TooManyRows> (C<P0003>)
1344  
1345 =back
1346  
1347 =item C<DBIx::Error::GeneralError> (C<S1000>)
1348  
1349 =item C<DBIx::Error::InternalError> (C<XX000>)
1350  
1351 =over
1352  
1353 =item C<DBIx::Error::DataCorrupted> (C<XX001>)
1354  
1355 =item C<DBIx::Error::IndexCorrupted> (C<XX002>)
1356  
1357 =cut
1358  
1359 #
1360 # END AUTOGENERATED DOCUMENTATION
1361 #
1362  
1363 =back
1364  
1365 =back
1366  
1367 =back
1368  
1369 =head1 AUTHOR
1370  
1371 Michael Brown <mbrown@fensystems.co.uk>
1372  
1373 =cut
1374  
1375 4 1;
↑ Summary