Write a short error message to log on connection errors

and save whole trace in other cases.

Tests added.

Change-Id: I068206691302a6d3d699458646d40c777134d11a
Closes-Bug: #1390457
Merge "Write a short error message to log on connection errors"