handle db.insert error

Fixed the bug where insertion error is not handled correctly.