|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of graze/queue. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) 2015 Nature Delivered Ltd. <https://www.graze.com> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @license https://github.com/graze/queue/blob/master/LICENSE MIT |
|
12
|
|
|
* |
|
13
|
|
|
* @link https://github.com/graze/queue |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Graze\Queue\Adapter\Exception; |
|
17
|
|
|
|
|
18
|
|
|
use Exception; |
|
19
|
|
|
use Graze\Queue\Adapter\AdapterInterface; |
|
20
|
|
|
use Graze\Queue\Adapter\NamedInterface; |
|
21
|
|
|
use Graze\Queue\Message\MessageInterface; |
|
22
|
|
|
use RuntimeException; |
|
23
|
|
|
|
|
24
|
|
|
class AdapterException extends RuntimeException |
|
25
|
|
|
{ |
|
26
|
|
|
/** @var AdapterInterface */ |
|
27
|
|
|
protected $adapter; |
|
28
|
|
|
/** @var array */ |
|
29
|
|
|
protected $debug; |
|
30
|
|
|
/** @var MessageInterface[] */ |
|
31
|
|
|
protected $messages; |
|
32
|
|
|
/** @var string|null */ |
|
33
|
|
|
protected $queueName; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param string $message |
|
37
|
|
|
* @param AdapterInterface $adapter |
|
38
|
|
|
* @param MessageInterface[] $messages |
|
39
|
|
|
* @param array $debug |
|
40
|
|
|
* @param Exception $previous |
|
41
|
|
|
*/ |
|
42
|
40 |
|
public function __construct( |
|
43
|
|
|
$message, |
|
44
|
|
|
AdapterInterface $adapter, |
|
45
|
|
|
array $messages, |
|
46
|
|
|
array $debug = [], |
|
47
|
|
|
Exception $previous = null |
|
48
|
|
|
) { |
|
49
|
40 |
|
$this->debug = $debug; |
|
50
|
40 |
|
$this->adapter = $adapter; |
|
51
|
40 |
|
$this->messages = $messages; |
|
52
|
|
|
|
|
53
|
40 |
|
if ($adapter instanceof NamedInterface) { |
|
54
|
9 |
|
$this->queueName = $adapter->getQueueName(); |
|
55
|
9 |
|
} |
|
56
|
|
|
|
|
57
|
40 |
|
parent::__construct($this->queueName . ': ' . $message, 0, $previous); |
|
58
|
40 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return AdapterInterface |
|
62
|
|
|
*/ |
|
63
|
6 |
|
public function getAdapter() |
|
64
|
|
|
{ |
|
65
|
6 |
|
return $this->adapter; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return array |
|
70
|
|
|
*/ |
|
71
|
9 |
|
public function getDebug() |
|
72
|
|
|
{ |
|
73
|
9 |
|
return $this->debug; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return \Graze\Queue\Message\MessageInterface[] |
|
78
|
|
|
*/ |
|
79
|
9 |
|
public function getMessages() |
|
80
|
|
|
{ |
|
81
|
9 |
|
return $this->messages; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return null|string |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function getQueueName() |
|
88
|
|
|
{ |
|
89
|
1 |
|
return $this->queueName; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|