Fix some error message handling

Change-Id: Ic7b8c5d0bee0809e3154bee8491590e5142729c9