Elgg  Version 4.3
PluginException.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Exceptions;
4 
12 class PluginException extends Exception {
13 
17  public function __construct(string $message = '', int $code = 0, \Throwable $previous = null) {
18  if (!$message) {
19  $message = elgg_echo('ElggPlugin:Error');
20  }
21 
22  parent::__construct($message, $code, $previous);
23  }
24 
36  public static function factory(array $options = []): self {
37  $message = $options['message'] ?? '';
38  $code = $options['code'] ?? 0;
39  $previous = $options['previous'] ?? null;
40 
41  $exception = new static($message, $code, $previous);
42 
43  $plugin = $options['plugin'] ?? null;
44  if ($plugin instanceof \ElggPlugin) {
45  $exception->plugin = $plugin;
46  }
47 
48  return $exception;
49  }
50 }
$plugin
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
$options
Elgg admin footer.
Definition: footer.php:6
static factory(array $options=[])
Create a new instance of a PluginException.
__construct(string $message= '', int $code=0,\Throwable $previous=null)
{}
$exception
Definition: error.php:15