move the exception throw to database layer