-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathUnsealException.php
More file actions
51 lines (45 loc) · 1.33 KB
/
UnsealException.php
File metadata and controls
51 lines (45 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Fingerprint\ServerAPI\Sealed;
use Exception;
/**
* Thrown when a single decryption key fails to unseal the data.
*
* Carries the {@see DecryptionKey} that was used, so callers can
* identify which key failed.
*/
class UnsealException extends Exception
{
private readonly DecryptionKey $decryptionKey;
/**
* Creates a new UnsealException instance.
*
* @param string $message error description
* @param Exception $cause underlying decryption exception
* @param DecryptionKey $decryptionKey the key that failed
*/
public function __construct(string $message, Exception $cause, DecryptionKey $decryptionKey)
{
parent::__construct($message, 0, $cause);
$this->decryptionKey = $decryptionKey;
}
/**
* Returns the decryption key that was used when this failure occurred.
*/
public function getDecryptionKey(): DecryptionKey
{
return $this->decryptionKey;
}
/**
* String representation of the exception.
*
* @return string
*/
public function __toString(): string
{
return 'UnsealException{'.
'decryptionKey='.$this->decryptionKey->getAlgorithm().
', message='.$this->getMessage().
', cause='.$this->getPrevious().
'}';
}
}