Skip to content

WP_CLI::error_to_string() doesn't have a guaranteed return value #5356

@schlessera

Description

@schlessera

The method WP_CLI::error_to_string() is supposed to accept an error object and return an error message that can be output.

However, if you pass a type into the method that it doesn't recognize, it doesn't return anything at all.

This should never happen. If it does nevertheless, it should throw an InvalidArgumentException to make sure a developer sees this and fix the problem.

The exception could use a message like the following:
Unsupported argument type passed to WP_CLI::error_to_string(): {$type}

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