Improve error handling during receiving data

Signed-off-by: Michael Heimpold <mhei@heimpold.de>