use toError in toArray