Fix throwing of errors