HandleError logs an error with an extra description and masks the error if it's an SQL one. The function ensures we never return plain SQL errors and leak anything. The function should be used for every database query error.
IsErrUniqueViolation determines is the given error is a unique contraint violation.
size of key and array should be both greater than 0