Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
OaiException | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
getOaiCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getOaiMessage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * OAI-PMH exception class |
5 | * |
6 | * PHP version 7 |
7 | * |
8 | * Copyright (c) Demian Katz 2021. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Harvest_Tools |
25 | * @author Demian Katz <demian.katz@villanova.edu> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/indexing:oai-pmh Wiki |
28 | */ |
29 | |
30 | namespace VuFindHarvest\Exception; |
31 | |
32 | use Throwable; |
33 | |
34 | /** |
35 | * OAI-PMH exception class |
36 | * |
37 | * @category VuFind |
38 | * @package Harvest_Tools |
39 | * @author Demian Katz <demian.katz@villanova.edu> |
40 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
41 | * @link https://vufind.org/wiki/indexing:oai-pmh Wiki |
42 | */ |
43 | class OaiException extends \RuntimeException |
44 | { |
45 | /** |
46 | * Error code |
47 | * |
48 | * @var string |
49 | */ |
50 | protected $oaiCode; |
51 | |
52 | /** |
53 | * Error message |
54 | * |
55 | * @var string |
56 | */ |
57 | protected $oaiMessage; |
58 | |
59 | /** |
60 | * Constructor |
61 | * |
62 | * @param string $oaiCode OAI-PMH error code |
63 | * @param string $oaiMessage OAI-PMH error message |
64 | * @param int $code Error code |
65 | * @param ?Throwable $previous Previous exception |
66 | */ |
67 | public function __construct( |
68 | string $oaiCode, |
69 | string $oaiMessage, |
70 | int $code = 0, |
71 | ?Throwable $previous = null |
72 | ) { |
73 | $this->oaiCode = $oaiCode; |
74 | $this->oaiMessage = $oaiMessage; |
75 | $message = "OAI-PMH error -- code: $oaiCode, value: $oaiMessage"; |
76 | parent::__construct($message, $code, $previous); |
77 | } |
78 | |
79 | /** |
80 | * Get OAI-PMH error code |
81 | * |
82 | * @return string |
83 | */ |
84 | public function getOaiCode(): string |
85 | { |
86 | return $this->oaiCode; |
87 | } |
88 | |
89 | /** |
90 | * Get OAI-PMH error message |
91 | * |
92 | * @return string |
93 | */ |
94 | public function getOaiMessage(): string |
95 | { |
96 | return $this->oaiMessage; |
97 | } |
98 | } |