xref: /plugin/struct/meta/StructException.php (revision d6d97f6064c3b0f90310be8341edc9585520ee54)
15511bd5bSAndreas Gohr<?php
25511bd5bSAndreas Gohr
3ba766201SAndreas Gohrnamespace dokuwiki\plugin\struct\meta;
45511bd5bSAndreas Gohr
55511bd5bSAndreas Gohr/**
65511bd5bSAndreas Gohr * Class StructException
75511bd5bSAndreas Gohr *
85511bd5bSAndreas Gohr * A translatable exception
95511bd5bSAndreas Gohr *
10ba766201SAndreas Gohr * @package dokuwiki\plugin\struct\meta
115511bd5bSAndreas Gohr */
12*d6d97f60SAnna Dabrowskaclass StructException extends \RuntimeException
13*d6d97f60SAnna Dabrowska{
145511bd5bSAndreas Gohr
1517560ecbSAndreas Gohr    protected $trans_prefix = 'Exception ';
1617560ecbSAndreas Gohr
175511bd5bSAndreas Gohr    /**
185511bd5bSAndreas Gohr     * StructException constructor.
195511bd5bSAndreas Gohr     *
205511bd5bSAndreas Gohr     * @param string $message
215511bd5bSAndreas Gohr     * @param ...string $vars
225511bd5bSAndreas Gohr     */
23*d6d97f60SAnna Dabrowska    public function __construct($message)
24*d6d97f60SAnna Dabrowska    {
25ba766201SAndreas Gohr        /** @var \helper_plugin_struct $plugin */
26ba766201SAndreas Gohr        $plugin = plugin_load('helper', 'struct');
2717560ecbSAndreas Gohr        $trans = $plugin->getLang($this->trans_prefix . $message);
285511bd5bSAndreas Gohr        if (!$trans) $trans = $message;
295511bd5bSAndreas Gohr
305511bd5bSAndreas Gohr        $args = func_get_args();
315511bd5bSAndreas Gohr        array_shift($args);
325511bd5bSAndreas Gohr
335511bd5bSAndreas Gohr        $trans = vsprintf($trans, $args);
345511bd5bSAndreas Gohr
355511bd5bSAndreas Gohr        parent::__construct($trans, -1, null);
365511bd5bSAndreas Gohr    }
375511bd5bSAndreas Gohr}
38