xref: /plugin/struct/meta/StructException.php (revision 0549dcc5bc88d4f9d923acdd09931d8d51be7097)
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
34        parent::__construct($trans, -1, null);
35    }
36}
37