ParseException/ODBC.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 67 CC 10 SCAR 43.0
CC
10
Cov
0%
error_handler
110.0
BEGIN
2.0
capabilities
2.0
CRAP 74.0
1 package DBIx::ParseException::ODBC;
2 BEGIN {
3 $DBIx::ParseException::ODBC::VERSION = '0.001000_03';
4 }
5  
6 use Moo;
7 use DBIx::Exceptions;
8  
9 my %error_codes = (
10 '00000' => {
11 group => 'ungrouped',
12 err_desc => "Success",
13 },
14 '01000' => {
15 group => 'ungrouped',
16 err_desc => "General warning",
17 },
18 '01002' => {
19 group => 'ungrouped',
20 err_desc => "Disconnect error",
21 },
22 '01004' => {
23 group => 'ungrouped',
24 err_desc => "Data truncated",
25 },
26 '01006' => {
27 group => 'ungrouped',
28 err_desc => "Privilege not revoked",
29 },
30 '01S00' => {
31 group => 'ungrouped',
32 err_desc => "Invalid connection string attribute",
33 },
34 '01S01' => {
35 group => 'ungrouped',
36 err_desc => "Error in row",
37 },
38 '01S02' => {
39 group => 'ungrouped',
40 err_desc => "Option value changed",
41 },
42 '01S03' => {
43 group => 'ungrouped',
44 err_desc => "No rows updated or deleted",
45 },
46 '01S04' => {
47 group => 'ungrouped',
48 err_desc => "More than one row updated or deleted",
49 },
50 '01S05' => {
51 group => 'ungrouped',
52 err_desc => "Cancel treated as FreeStmt/Close",
53 },
54 '01S06' => {
55 group => 'ungrouped',
56 err_desc => "Attempt to fetch before the result returned the first rowset",
57 },
58 '07001' => {
59 group => 'ungrouped',
60 err_desc => "Wrong number of parameters",
61 },
62 '07006' => {
63 group => 'ungrouped',
64 err_desc => "Restricted data type attribute violation",
65 },
66 '07S01' => {
67 group => 'ungrouped',
68 err_desc => "Invalid use of default paramater",
69 },
70 '08001' => {
71 group => 'ungrouped',
72 err_desc => "Unable to connect to data source",
73 },
74 '08002' => {
75 group => 'ungrouped',
76 err_desc => "Connection in use",
77 },
78 '08003' => {
79 group => 'ungrouped',
80 err_desc => "Connection not open",
81 },
82 '08004' => {
83 group => 'ungrouped',
84 err_desc => "Data source rejected establishment of connection",
85 },
86 '08007' => {
87 group => 'ungrouped',
88 err_desc => "Connection failure during transaction",
89 },
90 '08S01' => {
91 group => 'ungrouped',
92 err_desc => "Communication link failure",
93 },
94 '21S01' => {
95 group => 'ungrouped',
96 err_desc => "Insert value list does not match column list",
97 },
98 '21S02' => {
99 group => 'ungrouped',
100 err_desc => "Degree of derived table does not match column list",
101 },
102 '22001' => {
103 group => 'ungrouped',
104 err_desc => "String data right truncation",
105 },
106 '22002' => {
107 group => 'ungrouped',
108 err_desc => "Indicator variable required but not supplied",
109 },
110 '22003' => {
111 group => 'ungrouped',
112 err_desc => "Numeric value out of range",
113 },
114 '22005' => {
115 group => 'ungrouped',
116 err_desc => "Error in assignment",
117 },
118 '22008' => {
119 group => 'ungrouped',
120 err_desc => "Datetime field overflow",
121 },
122 '22012' => {
123 group => 'ungrouped',
124 err_desc => "Division by zero",
125 },
126 '22026' => {
127 group => 'ungrouped',
128 err_desc => "String data, length mismatch",
129 },
130 '23000' => {
131 group => 'constraint',
132 err_desc => "Integrity constraint violation",
133 class => 'NotNull'
134 },
135 'Invalid' => {
136 group => 'ungrouped',
137 err_desc => "cursor state",
138 },
139 '25000' => {
140 group => 'ungrouped',
141 err_desc => "Invalid transaction state",
142 },
143 '28000' => {
144 group => 'ungrouped',
145 err_desc => "Invalid authorization specification",
146 },
147 '34000' => {
148 group => 'ungrouped',
149 err_desc => "Invalid cursor name",
150 },
151 '37000' => {
152 group => 'ungrouped',
153 err_desc => "Syntax error or access violation",
154 },
155 '3C000' => {
156 group => 'ungrouped',
157 err_desc => "Duplicate cursor name",
158 },
159 '40001' => {
160 group => 'ungrouped',
161 err_desc => "Serialization failure",
162 },
163 '70100' => {
164 group => 'ungrouped',
165 err_desc => "Operation aborted",
166 },
167 'IM001' => {
168 group => 'ungrouped',
169 err_desc => "Driver does not support this function",
170 },
171 'IM002' => {
172 group => 'ungrouped',
173 err_desc => "Data source name not found and no default driver specified",
174 },
175 'IM003' => {
176 group => 'ungrouped',
177 err_desc => "Specified driver could not be loaded",
178 },
179 'IM004' => {
180 group => 'ungrouped',
181 err_desc => "Driver's SQLAllocEnv failed",
182 },
183 'IM005' => {
184 group => 'ungrouped',
185 err_desc => "Driver's SQLAllocConnect failed",
186 },
187 'IM006' => {
188 group => 'ungrouped',
189 err_desc => "Driver's SQLSetConnectOption failed",
190 },
191 'IM007' => {
192 group => 'ungrouped',
193 err_desc => "No data source or driver specified; dialog prohibited",
194 },
195 'IM008' => {
196 group => 'ungrouped',
197 err_desc => "Dialog failed",
198 },
199 'IM009' => {
200 group => 'ungrouped',
201 err_desc => "Unable to load translation DLL",
202 },
203 'IM010' => {
204 group => 'ungrouped',
205 err_desc => "Data source name too long",
206 },
207 'IM011' => {
208 group => 'ungrouped',
209 err_desc => "Driver name too long",
210 },
211 'IM012' => {
212 group => 'ungrouped',
213 err_desc => "DRIVER keyword syntax error",
214 },
215 'IM013' => {
216 group => 'ungrouped',
217 err_desc => "Trace file error",
218 },
219 'S0001' => {
220 group => 'ungrouped',
221 err_desc => "Base table or view already exists",
222 },
223 'S0002' => {
224 group => 'ungrouped',
225 err_desc => "Base table not found",
226 },
227 'S0011' => {
228 group => 'ungrouped',
229 err_desc => "Index already exists",
230 },
231 'S0012' => {
232 group => 'ungrouped',
233 err_desc => "Index not found",
234 },
235 'S0021' => {
236 group => 'ungrouped',
237 err_desc => "Column already exists",
238 },
239 'S0022' => {
240 group => 'ungrouped',
241 err_desc => "Column not found",
242 },
243 'S0023' => {
244 group => 'ungrouped',
245 err_desc => "No default for column",
246 },
247 'S1000' => {
248 group => 'ungrouped',
249 err_desc => "General error",
250 },
251 'S1001' => {
252 group => 'ungrouped',
253 err_desc => "Memory allocation failure",
254 },
255 'S1002' => {
256 group => 'ungrouped',
257 err_desc => "Invalid column number",
258 },
259 'S1003' => {
260 group => 'ungrouped',
261 err_desc => "Program type out of range",
262 },
263 'S1004' => {
264 group => 'ungrouped',
265 err_desc => "SQL data type out of range",
266 },
267 'S1008' => {
268 group => 'ungrouped',
269 err_desc => "Operation canceled",
270 },
271 'S1009' => {
272 group => 'ungrouped',
273 err_desc => "Invalid argument value",
274 },
275 'S1010' => {
276 group => 'ungrouped',
277 err_desc => "Function sequence error",
278 },
279 'S1011' => {
280 group => 'ungrouped',
281 err_desc => "Operation invalid at this time",
282 },
283 'S1012' => {
284 group => 'ungrouped',
285 err_desc => "Invalid transaction operation code specified",
286 },
287 'S1015' => {
288 group => 'ungrouped',
289 err_desc => "No cursor name available",
290 },
291 'S1090' => {
292 group => 'ungrouped',
293 err_desc => "Invalid string or buffer length",
294 },
295 'S1091' => {
296 group => 'ungrouped',
297 err_desc => "Descriptor type out of range",
298 },
299 'S1092' => {
300 group => 'ungrouped',
301 err_desc => "Option type out of range",
302 },
303 'S1093' => {
304 group => 'ungrouped',
305 err_desc => "Invalid parameter number",
306 },
307 'S1094' => {
308 group => 'ungrouped',
309 err_desc => "Invalid scale value",
310 },
311 'S1095' => {
312 group => 'ungrouped',
313 err_desc => "Function type out of range",
314 },
315 'S1096' => {
316 group => 'ungrouped',
317 err_desc => "Information type out of range",
318 },
319 'S1097' => {
320 group => 'ungrouped',
321 err_desc => "Column type out of range",
322 },
323 'S1098' => {
324 group => 'ungrouped',
325 err_desc => "Scope type out of range",
326 },
327 'S1099' => {
328 group => 'ungrouped',
329 err_desc => "Nullable type out of range",
330 },
331 'S1100' => {
332 group => 'ungrouped',
333 err_desc => "Uniqueness option type out of range",
334 },
335 'S1101' => {
336 group => 'ungrouped',
337 err_desc => "Accuracy option type out of range",
338 },
339 'S1103' => {
340 group => 'ungrouped',
341 err_desc => "Direction option out of range",
342 },
343 'S1104' => {
344 group => 'ungrouped',
345 err_desc => "Invalid precision value",
346 },
347 'S1105' => {
348 group => 'ungrouped',
349 err_desc => "Invalid parameter type",
350 },
351 'S1106' => {
352 group => 'ungrouped',
353 err_desc => "Fetch type out of range",
354 },
355 'S1107' => {
356 group => 'ungrouped',
357 err_desc => "Row value out of range",
358 },
359 'S1108' => {
360 group => 'ungrouped',
361 err_desc => "Concurrency option out of range",
362 },
363 'S1109' => {
364 group => 'ungrouped',
365 err_desc => "Invalid cursor position",
366 },
367 'S1110' => {
368 group => 'ungrouped',
369 err_desc => "Invalid driver completion",
370 },
371 'S1111' => {
372 group => 'ungrouped',
373 err_desc => "Invalid bookmark value",
374 },
375 'S1C00' => {
376 group => 'ungrouped',
377 err_desc => "Driver not capable",
378 },
379 'S1DE0' => {
380 group => 'ungrouped',
381 err_desc => "No data at execution values pending",
382 },
383 'S1T00' => {
384 group => 'ungrouped',
385 err_desc => "Timeout expired",
386 },
387 'SQLSTATE' => {
388 group => 'ungrouped',
389 err_desc => "Error",
390 },
391 '1000' => {
392 group => 'ungrouped',
393 err_desc => "General warning",
394 },
395 '1001' => {
396 group => 'ungrouped',
397 err_desc => "Cursor operation conflict",
398 },
399 '1002' => {
400 group => 'ungrouped',
401 err_desc => "Disconnect error",
402 },
403 '1003' => {
404 group => 'ungrouped',
405 err_desc => "NULL value eliminated in set function",
406 },
407 '1004' => {
408 group => 'ungrouped',
409 err_desc => "String data, right-truncated",
410 },
411 '1006' => {
412 group => 'ungrouped',
413 err_desc => "Privilege not revoked",
414 },
415 '1007' => {
416 group => 'ungrouped',
417 err_desc => "Privilege not granted",
418 },
419 '01S00' => {
420 group => 'ungrouped',
421 err_desc => "Invalid connection string attribute",
422 },
423 '01S01' => {
424 group => 'ungrouped',
425 err_desc => "Error in row",
426 },
427 '01S02' => {
428 group => 'ungrouped',
429 err_desc => "Option value changed",
430 },
431 '01S06' => {
432 group => 'ungrouped',
433 err_desc => "Attempt to fetch before the result set returned the first rowset",
434 },
435 '01S07' => {
436 group => 'ungrouped',
437 err_desc => "Fractional truncation",
438 },
439 '01S08' => {
440 group => 'ungrouped',
441 err_desc => "Error saving File DSN",
442 },
443 '01S09' => {
444 group => 'ungrouped',
445 err_desc => "Invalid keyword",
446 },
447 '7001' => {
448 group => 'ungrouped',
449 err_desc => "Wrong number of parameters",
450 },
451 '7002' => {
452 group => 'ungrouped',
453 err_desc => "COUNT field incorrect",
454 },
455 '7005' => {
456 group => 'ungrouped',
457 err_desc => "Prepared statement not a cursor-specification",
458 },
459 '7006' => {
460 group => 'ungrouped',
461 err_desc => "Restricted data type attribute violation",
462 },
463 '7009' => {
464 group => 'ungrouped',
465 err_desc => "Invalid descriptor index",
466 },
467 '07S01' => {
468 group => 'ungrouped',
469 err_desc => "Invalid use of default parameter",
470 },
471 '8001' => {
472 group => 'ungrouped',
473 err_desc => "Client unable to establish connection",
474 },
475 '8002' => {
476 group => 'ungrouped',
477 err_desc => "Connection name in use",
478 },
479 '8003' => {
480 group => 'ungrouped',
481 err_desc => "Connection not open",
482 },
483 '8004' => {
484 group => 'ungrouped',
485 err_desc => "Server rejected the connection",
486 },
487 '8007' => {
488 group => 'ungrouped',
489 err_desc => "Connection failure during transaction",
490 },
491 '08S01' => {
492 group => 'ungrouped',
493 err_desc => "Communication link failure",
494 },
495 '21S01' => {
496 group => 'ungrouped',
497 err_desc => "Insert value list does not match column list",
498 },
499 '21S02' => {
500 group => 'ungrouped',
501 err_desc => "Degree of derived table does not match column list",
502 },
503 '22001' => {
504 group => 'ungrouped',
505 err_desc => "String data, right-truncated",
506 },
507 '22002' => {
508 group => 'ungrouped',
509 err_desc => "Indicator variable required but not supplied",
510 },
511 '22003' => {
512 group => 'ungrouped',
513 err_desc => "Numeric value out of range",
514 },
515 '22007' => {
516 group => 'ungrouped',
517 err_desc => "Invalid datetime format",
518 },
519 '22008' => {
520 group => 'ungrouped',
521 err_desc => "Datetime field overflow",
522 },
523 '22012' => {
524 group => 'ungrouped',
525 err_desc => "Division by zero",
526 },
527 '22015' => {
528 group => 'ungrouped',
529 err_desc => "Interval field overflow",
530 },
531 '22018' => {
532 group => 'ungrouped',
533 err_desc => "Invalid character value for cast specification",
534 },
535 '22019' => {
536 group => 'ungrouped',
537 err_desc => "Invalid escape character",
538 },
539 '22025' => {
540 group => 'ungrouped',
541 err_desc => "Invalid escape sequence",
542 },
543 '22026' => {
544 group => 'ungrouped',
545 err_desc => "String data, length mismatch",
546 },
547 '24000' => {
548 group => 'ungrouped',
549 err_desc => "Invalid cursor state",
550 },
551 '25000' => {
552 group => 'ungrouped',
553 err_desc => "Invalid transaction state",
554 },
555 '25S01' => {
556 group => 'ungrouped',
557 err_desc => "Transaction state",
558 },
559 '25S02' => {
560 group => 'ungrouped',
561 err_desc => "Transaction is still active",
562 },
563 '25S03' => {
564 group => 'ungrouped',
565 err_desc => "Transaction is rolled back",
566 },
567 '28000' => {
568 group => 'ungrouped',
569 err_desc => "Invalid authorization specification",
570 },
571 '34000' => {
572 group => 'ungrouped',
573 err_desc => "Invalid cursor name",
574 },
575 '3C000' => {
576 group => 'ungrouped',
577 err_desc => "Duplicate cursor name",
578 },
579 '3D000' => {
580 group => 'ungrouped',
581 err_desc => "Invalid catalog name",
582 },
583 '3F000' => {
584 group => 'ungrouped',
585 err_desc => "Invalid schema name",
586 },
587 '40001' => {
588 group => 'ungrouped',
589 err_desc => "Serialization failure",
590 },
591 '40002' => {
592 group => 'ungrouped',
593 err_desc => "Integrity constraint violation",
594 },
595 '40003' => {
596 group => 'ungrouped',
597 err_desc => "Statement completion unknown",
598 },
599 '42000' => {
600 group => 'syntax',
601 err_desc => "Syntax error or access violation",
602 class => 'Syntax'
603 },
604 '42S01' => {
605 group => 'ungrouped',
606 err_desc => "Base table or view already exists",
607 },
608 '42S02' => {
609 group => 'no_such',
610 err_desc => "Base table or view not found",
611 class => 'NoSuchTable'
612 },
613 '42S11' => {
614 group => 'ungrouped',
615 err_desc => "Index already exists",
616 },
617 '42S12' => {
618 group => 'ungrouped',
619 err_desc => "Index not found",
620 },
621 '42S21' => {
622 group => 'ungrouped',
623 err_desc => "Column already exists",
624 },
625 '42S22' => {
626 group => 'no_such',
627 err_desc => "Column not found",
628 class => 'NoSuchColumn'
629 },
630 '44000' => {
631 group => 'ungrouped',
632 err_desc => "WITH CHECK OPTION violation",
633 },
634 'HY000' => {
635 group => 'ungrouped',
636 err_desc => "General error",
637 },
638 'HY001' => {
639 group => 'ungrouped',
640 err_desc => "Memory allocation error",
641 },
642 'HY003' => {
643 group => 'ungrouped',
644 err_desc => "Invalid application buffer type",
645 },
646 'HY004' => {
647 group => 'ungrouped',
648 err_desc => "Invalid SQL data type",
649 },
650 'HY007' => {
651 group => 'ungrouped',
652 err_desc => "Associated statement is not prepared",
653 },
654 'HY008' => {
655 group => 'ungrouped',
656 err_desc => "Operation canceled",
657 },
658 'HY009' => {
659 group => 'ungrouped',
660 err_desc => "Invalid use of null pointer",
661 },
662 'HY010' => {
663 group => 'ungrouped',
664 err_desc => "Function sequence error",
665 },
666 'HY011' => {
667 group => 'ungrouped',
668 err_desc => "Attribute cannot be set now",
669 },
670 'HY012' => {
671 group => 'ungrouped',
672 err_desc => "Invalid transaction operation code",
673 },
674 'HY013' => {
675 group => 'ungrouped',
676 err_desc => "Memory management error",
677 },
678 'HY014' => {
679 group => 'ungrouped',
680 err_desc => "Limit on the number of handles exceeded",
681 },
682 'HY015' => {
683 group => 'ungrouped',
684 err_desc => "No cursor name available",
685 },
686 'HY016' => {
687 group => 'ungrouped',
688 err_desc => "Cannot modify an implementation row descriptor",
689 },
690 'HY017' => {
691 group => 'ungrouped',
692 err_desc => "Invalid use of an automatically allocated descriptor handle",
693 },
694 'HY018' => {
695 group => 'ungrouped',
696 err_desc => "Server declined cancel request",
697 },
698 'HY019' => {
699 group => 'ungrouped',
700 err_desc => "Non-character and non-binary data sent in pieces",
701 },
702 'HY020' => {
703 group => 'ungrouped',
704 err_desc => "Attempt to concatenate a null value",
705 },
706 'HY021' => {
707 group => 'ungrouped',
708 err_desc => "Inconsistent descriptor information",
709 },
710 'HY024' => {
711 group => 'ungrouped',
712 err_desc => "Invalid attribute value",
713 },
714 'HY090' => {
715 group => 'ungrouped',
716 err_desc => "Invalid string or buffer length",
717 },
718 'HY091' => {
719 group => 'ungrouped',
720 err_desc => "Invalid descriptor field identifier",
721 },
722 'HY092' => {
723 group => 'ungrouped',
724 err_desc => "Invalid attribute/option identifier",
725 },
726 'HY095' => {
727 group => 'ungrouped',
728 err_desc => "Function type out of range",
729 },
730 'HY096' => {
731 group => 'ungrouped',
732 err_desc => "Invalid information type",
733 },
734 'HY097' => {
735 group => 'ungrouped',
736 err_desc => "Column type out of range",
737 },
738 'HY098' => {
739 group => 'ungrouped',
740 err_desc => "Scope type out of range",
741 },
742 'HY099' => {
743 group => 'ungrouped',
744 err_desc => "Nullable type out of range",
745 },
746 'HY100' => {
747 group => 'ungrouped',
748 err_desc => "Uniqueness option type out of range",
749 },
750 'HY101' => {
751 group => 'ungrouped',
752 err_desc => "Accuracy option type out of range",
753 },
754 'HY103' => {
755 group => 'ungrouped',
756 err_desc => "Invalid retrieval code",
757 },
758 'HY104' => {
759 group => 'ungrouped',
760 err_desc => "Invalid precision or scale value",
761 },
762 'HY105' => {
763 group => 'ungrouped',
764 err_desc => "Invalid parameter type",
765 },
766 'HY106' => {
767 group => 'ungrouped',
768 err_desc => "Fetch type out of range",
769 },
770 'HY107' => {
771 group => 'ungrouped',
772 err_desc => "Row value out of range",
773 },
774 'HY109' => {
775 group => 'ungrouped',
776 err_desc => "Invalid cursor position",
777 },
778 'HY110' => {
779 group => 'ungrouped',
780 err_desc => "Invalid driver completion",
781 },
782 'HY111' => {
783 group => 'ungrouped',
784 err_desc => "Invalid bookmark value",
785 },
786 'HYC00' => {
787 group => 'ungrouped',
788 err_desc => "Optional feature not implemented",
789 },
790 'HYT00' => {
791 group => 'ungrouped',
792 err_desc => "Timeout expired",
793 },
794 'HYT01' => {
795 group => 'ungrouped',
796 err_desc => "Connection timeout expired",
797 },
798 'IM001' => {
799 group => 'ungrouped',
800 err_desc => "Driver does not support this function",
801 },
802 'IM002' => {
803 group => 'ungrouped',
804 err_desc => "Data source name not found and no default driver specified",
805 },
806 'IM003' => {
807 group => 'ungrouped',
808 err_desc => "Specified driver could not be loaded",
809 },
810 'IM004' => {
811 group => 'ungrouped',
812 err_desc => "Driver's SQLAllocHandle on SQL_HANDLE_ENV failed",
813 },
814 'IM005' => {
815 group => 'ungrouped',
816 err_desc => "Driver's SQLAllocHandle on SQL_HANDLE_DBC failed",
817 },
818 'IM006' => {
819 group => 'ungrouped',
820 err_desc => "Driver's SQLSetConnectAttr failed",
821 },
822 'IM007' => {
823 group => 'ungrouped',
824 err_desc => "No data source or driver specified; dialog prohibited",
825 },
826 'IM008' => {
827 group => 'ungrouped',
828 err_desc => "Dialog failed",
829 },
830 'IM009' => {
831 group => 'ungrouped',
832 err_desc => "Unable to load translation DLL",
833 },
834 'IM010' => {
835 group => 'ungrouped',
836 err_desc => "Data source name too long",
837 },
838 'IM011' => {
839 group => 'ungrouped',
840 err_desc => "Driver name too long ",
841 },
842 'IM012' => {
843 group => 'ungrouped',
844 err_desc => "DRIVER keyword syntax error",
845 },
846 'IM013' => {
847 group => 'ungrouped',
848 err_desc => "Trace file error",
849 },
850 'IM014' => {
851 group => 'ungrouped',
852 err_desc => "Invalid name of File DSN",
853 },
854 'IM015' => {
855 group => 'ungrouped',
856 err_desc => "Corrupt file data source",
857 },
858 );
859  
860 sub capabilities { $_[0] }
861  
862 sub error_handler {
863 my $string = shift;
864  
865 my $dbh = shift;
866 my $code = $dbh->state;
867  
868 #the old code is what we really want
869 if ( $string =~ m/\[state was (.*) now (.*)\]/ ) {
870 $code = $1
871 }
872  
873 my $error_info = $error_codes{$code};
874  
875 # prepare class
876 my $class = 'DBIx::Exception';
877 my $group = '';
878 if ($string =~ m/Violation of UNIQUE KEY constraint/){
879 $class .= '::NotUnique';
880 $group = 'constraint';
881 } elsif (my $class_ext = $error_info->{class}) {
882 $class .= "::$class_ext";
883 $group = $error_info->{group};
884 }
885  
886 # prepare args
887 my @args = ( original => $string );
888 if ($group eq 'constraint') {
889 # fk constraints, unique constraints etc
890 my ($constraint) = $string =~ /Violation of UNIQUE KEY constraint '.+'/;
891 push @args, ( constraint => $constraint );
892 my ($column_name) = $string =~ /column '(.+)', table/;
893 push @args, ( column => $column_name ) if $column_name;
894 } elsif ($group eq 'no_such') {
895 # wrong table, wrong column etc
896 my ($table_name) = $string =~ /Invalid object name '(.+)'/;
897 my ($column_name) = $string =~ /Invalid column name '(.+)'\./;
898 push @args, ( table => $table_name ) if $table_name;
899 push @args, ( column => $column_name ) if $column_name;
900 } elsif ($group eq 'syntax') {
901 my ($near) = $string =~ /near "(.+)"/;
902 push @args, ( near => $near );
903 }
904  
905 $class->throw(@args);
906 }
907  
908 use constant {
909 can_unique_constraint => 1,
910 can_unique_constraint_column => 0,
911  
912 can_syntax => 1,
913 can_syntax_near => 0,
914  
915 can_no_such_table => 1,
916 can_no_such_table_table => 1,
917  
918 can_no_such_column => 1,
919 can_no_such_column_table => 0,
920 can_no_such_column_column => 1,
921 };
922  
923 1;
924  
925 __END__