xref: /plugin/dw2pdf/src/ExportException.php (revision 4c5691130dbf9035b960f10f5b3cb4b319a026d8)
1*4c569113SAndreas Gohr<?php
2*4c569113SAndreas Gohr
3*4c569113SAndreas Gohrnamespace dokuwiki\plugin\dw2pdf\src;
4*4c569113SAndreas Gohr
5*4c569113SAndreas Gohr/**
6*4c569113SAndreas Gohr * Signals an expected, user-facing failure during PDF export
7*4c569113SAndreas Gohr *
8*4c569113SAndreas Gohr * The exception message is a language key. Optional arguments are applied to the
9*4c569113SAndreas Gohr * translated string via vsprintf(), allowing the message to be localized where it
10*4c569113SAndreas Gohr * is displayed to the user.
11*4c569113SAndreas Gohr */
12*4c569113SAndreas Gohrclass ExportException extends \Exception
13*4c569113SAndreas Gohr{
14*4c569113SAndreas Gohr    /** @var array Arguments to fill placeholders in the translated message */
15*4c569113SAndreas Gohr    protected array $args;
16*4c569113SAndreas Gohr
17*4c569113SAndreas Gohr    /**
18*4c569113SAndreas Gohr     * @param string $langKey Language key describing the failure
19*4c569113SAndreas Gohr     * @param array $args Arguments applied to the translated string via vsprintf()
20*4c569113SAndreas Gohr     */
21*4c569113SAndreas Gohr    public function __construct(string $langKey, array $args = [])
22*4c569113SAndreas Gohr    {
23*4c569113SAndreas Gohr        parent::__construct($langKey);
24*4c569113SAndreas Gohr        $this->args = $args;
25*4c569113SAndreas Gohr    }
26*4c569113SAndreas Gohr
27*4c569113SAndreas Gohr    /**
28*4c569113SAndreas Gohr     * Get the arguments to fill placeholders in the translated message
29*4c569113SAndreas Gohr     *
30*4c569113SAndreas Gohr     * @return array
31*4c569113SAndreas Gohr     */
32*4c569113SAndreas Gohr    public function getArgs(): array
33*4c569113SAndreas Gohr    {
34*4c569113SAndreas Gohr        return $this->args;
35*4c569113SAndreas Gohr    }
36*4c569113SAndreas Gohr}
37