15511bd5bSAndreas Gohr<?php 25511bd5bSAndreas Gohr 35511bd5bSAndreas Gohrnamespace plugin\struct\meta; 45511bd5bSAndreas Gohr 55511bd5bSAndreas Gohr/** 65511bd5bSAndreas Gohr * Class StructException 75511bd5bSAndreas Gohr * 85511bd5bSAndreas Gohr * A translatable exception 95511bd5bSAndreas Gohr * 105511bd5bSAndreas Gohr * @package plugin\struct\meta 115511bd5bSAndreas Gohr */ 125511bd5bSAndreas Gohrclass StructException extends \RuntimeException { 135511bd5bSAndreas Gohr 14*17560ecbSAndreas Gohr protected $trans_prefix = 'Exception '; 15*17560ecbSAndreas Gohr 165511bd5bSAndreas Gohr /** 175511bd5bSAndreas Gohr * StructException constructor. 185511bd5bSAndreas Gohr * 195511bd5bSAndreas Gohr * @param string $message 205511bd5bSAndreas Gohr * @param ...string $vars 215511bd5bSAndreas Gohr */ 225511bd5bSAndreas Gohr public function __construct($message) { 235511bd5bSAndreas Gohr /** @var \action_plugin_struct_autoloader $plugin */ 245511bd5bSAndreas Gohr $plugin = plugin_load('action', 'struct_autoloader'); 25*17560ecbSAndreas Gohr $trans = $plugin->getLang($this->trans_prefix . $message); 265511bd5bSAndreas Gohr if(!$trans) $trans = $message; 275511bd5bSAndreas Gohr 285511bd5bSAndreas Gohr $args = func_get_args(); 295511bd5bSAndreas Gohr array_shift($args); 305511bd5bSAndreas Gohr 315511bd5bSAndreas Gohr $trans = vsprintf($trans, $args); 325511bd5bSAndreas Gohr 335511bd5bSAndreas Gohr parent::__construct($trans, -1, null); 345511bd5bSAndreas Gohr } 355511bd5bSAndreas Gohr} 36