Added exception logging. Also check for exception and