Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Unique key and exception hanhling


Reply


3 Posts   668 Views

Avatar
mishell

Community Member, 19 Posts

23 August 2011 at 1:22am

I have unique index on two fields (COL1,CoL2)

I wanna write it to DB, but on failure I don't want to throw any user error. Just that one that I want to show. I made

try {
$branch->write();
}
catch(ValidationException $e) {
$bad++
show_error_with_bad_results($bad);
}

but It doesn't seem to catch it. I t throws user error instead. How could I make it work.

Avatar
Willr

Forum Moderator, 5513 Posts

23 August 2011 at 8:08pm

SS doesn't use exceptions very much, I think in this case you'll need to manually do your insert or detect the conflict. There is a plan to get us away from the user_error() world but that's a big task!

Avatar
mishell

Community Member, 19 Posts

23 August 2011 at 8:35pm

I thought I can make it by DO, if now well... Thank You anyway.

M.