WP_Error not displaying errors

Actions don’t typically return data, so I doubt you will get this working the way you are trying to. Something like…

function cpt_pre_post_publish(){
  global $my_error;
  $my_error = new WP_Error('error', __('Error!' ));
}
add_action('pre_get_posts', 'cpt_pre_post_publish');

… should set a variable that you could access in a template file with…

global $my_error;
var_dump($my_error);

It is really not clear exactly what you are trying to do though.