This documentation describes unreleased changes on the main branch.

CliException

Class. It extends RuntimeException.

use Saij\WpAppFramework\WpCli\CliException;

Ends a WP-CLI command with an error: thrown from a #[CliSubcommand] method, WP-CLI prints Error: {message} and exits with the given code.

Constructor

new CliException(string $message, int $exitCode = 1, ?Throwable $previous = null)
ParameterTypeDefaultDescription
messagestringrequiredThe error message WP-CLI prints after Error: .
exitCodeint1Exit code of the command, 1–255.
previousThrowable|nullnullThe exception that caused this one, if any.

Methods

getExitCode()

getExitCode(): int

The exit code of the command, 1 to 255.

Returns int