save_post Error Reporting Boilerplate

add_action( 'admin_notices', 'my_error_message' );
add_action( 'save_post', 'my_save_post_function' );
function my_save_function( $post_id ) {
    $error = false;

    // Do stuff.

    if ($something_went_wrong) {
        $error = new WP_Error($code, $msg);        
    }

    if ($error) {
        // Handle error.
    }

    return true;
}