DBIx::Class::ParseError - Extensible database error handler
From:
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry \'1\' for key \'PRIMARY\' [for Statement "INSERT INTO foo ( bar_id, id, is_foo, name) VALUES ( ?, ?, ?, ? )" with ParamValues: 0=1, 1=1, 2=1, 3=\'Foo1571434801\'] at ...
To:
use Data::Dumper; my $parser = DBIx::Class::ParseError->new(schema => $dbic_schema); print Dumper( $parser->process($error) ); # bless({ # 'table' => 'foo', # 'columns' => [ # 'id' # ], # 'message' => 'DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry \'1\' for key \'PRIMARY\' [for Statement "INSERT INTO foo ( bar_id, id, is_foo, name) VALUES ( ?, ?, ?, ? )" with ParamValues: 0=1, 1=1, 2=1, 3=\'Foo1571434801\'] at ...', # 'operation' => 'insert', # 'column_data' => { # 'name' => 'Foo1571434801', # 'bar_id' => '1', # 'id' => '1', # 'is_foo' => '1' # }, # 'source_name' => 'Foo', # 'type' => 'primary_key' # }, 'DBIx::Class::ParseError::Error' );
This a tool to extend DB errors from DBIx::Class (basically, database error strings wrapped into a DBIx::Class::Exception obj) into an API to provide useful details of the error, allowing app's business layer or helper scripts interfacing with database models to instrospect and better handle errors from multiple DBMS.
This is a non-exausted list of common errors which should be handled by this tool:
Initial fully support for errors from the following DBMS:
See DBIx::Class::ParseError::Parser::SQLite.
See DBIx::Class::ParseError::Parser::MySQL.
wreis - Wallace reis <wreis@cpan.org>
Copyright (c) the "AUTHOR" and "CONTRIBUTORS" as listed above.
This library is free software and may be distributed under the same terms as perl itself.
This module exists due to the wonderful people at IntelliTree Solutions http://www.intellitree.com.
To install DBIx::Class::ParseError, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::ParseError
CPAN shell
perl -MCPAN -e shell install DBIx::Class::ParseError
For more information on module installation, please visit the detailed CPAN module installation guide.