Only show error message when err != 0

fixes #307