Add exception and log mechanism