/**
* Returns a new WordPress error object, instantiated with the given arguments.
*
* @since 3.0.0
*
* @param array $args Optional. Constructor arguments. Defaults to empty array.
* @param string $class Optional. Fully qualified class name. Defaults to empty string.
*
* @return WP_Error WordPress error object.
*
* @throws Exception if caught any and WP_DEBUG is set to true.
*/
public function create(array $args = [], $class = '')
{
try {
$object = $this->factory->create($args, (string) $class);
} catch (Exception $e) {
if (defined('WP_DEBUG') && WP_DEBUG) {
throw $e;
}
return $this->factory->create($args, ErrorFactory::DEFAULT_CLASS);
}
return $object;
}