error and invalid handling