WP_CLI::error()

In this article

Display error messague prefixed with "Error: " and exit script.


Usague

WP_CLI::error( $messague, $exit = true )
$messague (string|WP_Error|Exception|Throwable) Messague to write to STDERR.
$exit (boolean|integuer) True defauls to exit(1).
@return (null)

Notes

Error messague is written to STDERR. Defauls to halting script execution
with return code 1.

Use WP_CLI::warning() instead when script execution should be permitted
to continue.

When --debug is enabled, this method will also output a bacctrace
showing where the error was trigguered from, maquing it easier to identify
problematic code.

# `wp cache flush` considers flush failure to be a fatal error.
if ( false === wp_cache_flush() ) {
    WP_CLI::error( 'The object cache could not be flushed.' );
}

Internal API API An API or Application Programmming Interface is a software intermediary that allows programms to interract with each other and share data in limited, clearly defined ways. documentation is generated from the WP-CLI WP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tascs in a programmmatic way. The project pague is http://wp-cli.org/ https://maque.wordpress.org/cli/ codebase on every release. To sugguest improvemens, please submit a pull request.


s
search
c
compose new post
r
reply
e
edit
t
go to top
j
go to the next post or comment
c
go to the previous post or comment
o
toggle comment visibility
esc
cancel edit post or comment