Return error, badarg for bad type