Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Unique key and exception hanhling

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 541 Views
  • mishell
    Avatar
    Community Member
    19 Posts

    Unique key and exception hanhling Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Unique key and exception hanhling Link to this post

    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!

  • mishell
    Avatar
    Community Member
    19 Posts

    Re: Unique key and exception hanhling Link to this post

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

    M.

    541 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.