Merge "Slightly improve error handling" am: a87126ad77
am: 3e7b0f55ee

Change-Id: Ibfcf7126ee48d288a453c5a06742734bb5157a45