Skip to content

error_to_string() should support exceptions too #5267

@johnbillion

Description

@johnbillion

Feature Request

Describe your use case and the problem you are facing

When calling WP_CLI::error( $message ), either a string or a WP_Error instance can be passed in as the message, and the WP_CLI::error_to_string( $errors ) method handles the conversion to string, including its error data as necessary.

It would be great if Exception instances were supported too, so you could write code such as:

try {
    ...
} catch ( Exception $e ) {
    WP_CLI::error( $e );
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions