Infer throws error type rather than string