Add log and exception handling