1<?php 2 3namespace dokuwiki\plugin\struct\meta; 4 5/** 6 * Class StructException 7 * 8 * A translatable exception 9 * 10 * @package dokuwiki\plugin\struct\meta 11 */ 12class StructException extends \RuntimeException 13{ 14 protected $trans_prefix = 'Exception '; 15 16 /** 17 * StructException constructor. 18 * 19 * @param string $message 20 * @param ...string $vars 21 */ 22 public function __construct($message) 23 { 24 /** @var \helper_plugin_struct $plugin */ 25 $plugin = plugin_load('helper', 'struct'); 26 $trans = $plugin->getLang($this->trans_prefix . $message); 27 if (!$trans) $trans = $message; 28 29 $args = func_get_args(); 30 array_shift($args); 31 32 $trans = vsprintf($trans, $args); 33 $trans .= $this->getVersionPostfix(); 34 35 parent::__construct($trans, -1, null); 36 } 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 } 49} 50