Initialize error instance correctly. Based on @kemkin's patch.