Elgg  Version 3.0
PluginException.php
Go to the documentation of this file.
1 <?php
2 
10 
14  protected $plugin;
15 
26  public static function factory(
27  $reason,
28  ElggPlugin $plugin = null,
29  $message = null,
30  Throwable $previous = null
31  ) {
32  if ($plugin) {
33  try {
34  if ($plugin->getID()) {
35  $info = elgg_echo("ElggPlugin:Error:ID", [$plugin->getID()]);
36  } else {
37  $info = elgg_echo("ElggPlugin:Error:Path", [$plugin->getPath()]);
38  }
39  } catch (Exception $ex) {
40  $info = elgg_echo("ElggPlugin:Error:Unknown");
41  }
42  } else {
43  $info = elgg_echo("ElggPlugin:Error");
44  }
45 
46  if (!isset($message)) {
47  $message = elgg_echo("ElggPlugin:Exception:$reason");
48  }
49 
51 
52  $exception = new static("$info: $message", $code, $previous);
53 
54  $exception->setParams([
55  'reason' => $reason,
56  'plugin' => $plugin,
57  ]);
58 
59  return $exception;
60  }
61 
65  public function __construct(string $message = "", int $code = 0, Throwable $previous = null) {
66  if (!$message) {
67  $message = elgg_echo("ElggPlugin:Error");
68  }
69  if (!$code) {
71  }
72  parent::__construct($message, $code, $previous);
73  }
74 }
Generic HTTP exception.
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
PluginException.
$code
static factory($reason, ElggPlugin $plugin=null, $message=null, Throwable $previous=null)
Create a new plugin exception.
$exception
if(!empty($screenshots)) $info
Definition: details.php:59
__construct(string $message="", int $code=0, Throwable $previous=null)
{}
const ELGG_HTTP_INTERNAL_SERVER_ERROR
Definition: constants.php:106