Quoting Ash Berlin <[EMAIL PROTECTED]>:
> A method on the storage object (which is subclassed to be the
> particular type of DBI you are connecting to, eg
> DBIx::Class::Storage::DBI::mysql) which parses and encapsulates the
> error as returned from the database to mark its type, e.g. FK
> constraint violation, duplicate key, etc. etc.
> Then you could check [EMAIL PROTECTED]>type eq 'duplicate_key' or something.

Sounds good! What do the others think?

I believe I'm not really suited for making these changes deep down in the guts
of DBIC because I know next to nothing about the internals. Maybe somebody with
more knowledge could lay down a more detailed plan which I can use to implement?

Currently I understand the proposed solution to work something like this:

1. Have a _parse_error() method in DBIx::Class::Storage::DBI which takes $@
   and by default just dies with the error provided. DBIx::Class::Storage::DBI
   subclasses (like mysql) can override this method to return an appropriate,
   standardized exception object(?) (Can DBIx::Class::Exception be used for
   this?)

2. Wrap the dbh_do() call inside DBIx::Class::Storage::DBI's _execute()
   method with an eval{}.

3. Afterwards check $@ and, if applicable, utilize _parse_error() to create
   the standardized exception.

Am I completely off track? :)

--Tobias

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to