Fixed bug where error code for duplicate entries in db was handled in a wrong way