Correctly detect error on string-to-number conversion.

Signed-off-by: Thorben Hasenpusch <thorben.hasenpusch@gmail.com>