How to handle db constraint violations in the user interface?

后端 未结 6 1422
暖寄归人
暖寄归人 2021-02-05 15:37

We implement the majority of our business rules in the database, using stored procs.

I can never decide how best to pass data constraint violation errors from the databa

6条回答
  •  余生分开走
    2021-02-05 16:33

    In defense of #4, SQL Server has a pretty orderly hierarchy of error severity levels predefined. Since as you point out it's well to handle errors where the logic is, I'd be inclined to handle this by convention between the SP and the UI abstraction, rather than adding a bunch of extra coupling. Especially since you can raise errors with both a value and a string.

提交回复
热议问题