Handle exceptions separately and added an else block for success cases.