ERROR: duplicate key value violates unique constraint

hmm, I created an index for 2 fields in a table (and added uniqueness to it). It definitely prevents duplicate keys from entering in the table, but how would I handle this error instead of it crashing the application with the 'ERROR: duplicate key value violates unique constraint ’ error msg.

Thanks, Joe

ok I think i found out how.