Logging api exceptions properly