split error function into plugin;