Closed awakash closed 1 year ago
I don't really understand this. What do you mean by debug info, error text, and 500 error in the console?
When there's an exact match of an existing url in the db, I'd like to set an error in the UI and note that the redirect was not created because it already exists.
if ( $new_url == $existing_url ) {
// Might be a better way to show the error?
$error = new WP_Error(
'Unable to create redirect!', _(' Redirect ' . $new_url . ' already exists.'), array( 'response' => '200' )
);
if ( is_wp_error($error) ){
wp_die( $error );
}
}
Appears as:
Is there a better way of handling the error?
You may be better hooking into the core WordPress REST API functions. By calling wp_die
you are forcing an error - there is no way around that.
Hello,
I'm using the action
add_action( 'redirection_create_redirect', 'mysite_prevent_dupe_redirect' );
to prevent an existing redirect from being created. I'm using wp_die to show the error within thewpl-error
error/debug div. Any ideas on how not to show all the debug info except for the error text I'd like to appear; along with 500 error in the console?