Fixes DB error & error handling;

Signed-off-by: ashwinh <ashwinh@cybage.com>