For inserts into a table with defined constriants is it proper to test the consraints prior to inserting a new record or just catch the exception.
Option 1
Data Layer psudo code
Function Exists(Item) boolean
Sub Add(Item)
UI
If Not Exists(item) then
Add(Item)
Else
Show Message
Option 2
Data Layer
Sub Add(Item)
UI
Try
Add(Item)
Catch
Show Message
Option 1
Data Layer psudo code
Function Exists(Item) boolean
Sub Add(Item)
UI
If Not Exists(item) then
Add(Item)
Else
Show Message
Option 2
Data Layer
Sub Add(Item)
UI
Try
Add(Item)
Catch
Show Message