Skip to content

Commit 2d502a6

Browse files
committed
Add plugin version to exceptions
This should help analysing log files in bug reports
1 parent 4831b32 commit 2d502a6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

meta/StructException.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,20 @@ public function __construct($message)
3030
array_shift($args);
3131

3232
$trans = vsprintf($trans, $args);
33+
$trans .= $this->getVersionPostfix();
3334

3435
parent::__construct($trans, -1, null);
3536
}
37+
38+
/**
39+
* Get the plugin version to add as postfix to the exception message
40+
* @return string
41+
*/
42+
protected function getVersionPostfix()
43+
{
44+
/** @var \helper_plugin_struct $plugin */
45+
$plugin = plugin_load('helper', 'struct');
46+
$info = $plugin->getInfo();
47+
return ' [struct ' . $info['date'] . ']';
48+
}
3649
}

meta/ValidationException.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@
1212
class ValidationException extends StructException
1313
{
1414
protected $trans_prefix = 'Validation Exception ';
15+
16+
/**
17+
* No version postfix on validation errors
18+
*/
19+
protected function getVersionPostfix()
20+
{
21+
return '';
22+
}
23+
24+
1525
}

0 commit comments

Comments
 (0)