Added error handling when failing to read ui field.
Implemented error handling for primary key violations.