-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermissionDeniedException.php
More file actions
35 lines (31 loc) · 982 Bytes
/
PermissionDeniedException.php
File metadata and controls
35 lines (31 loc) · 982 Bytes
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
<?php
declare(strict_types=1);
namespace Arcp\Errors;
/**
* RFC §15, §18.2 — caller lacks the required permission or lease.
*
* `permission` is the dotted-name of the required capability
* (e.g. `payment.refund.create`), `resource` is the resource the operation
* was attempted against. Both are surfaced on the wire under `details`.
*/
final class PermissionDeniedException extends ARCPException
{
public function __construct(
public readonly string $permission,
public readonly string $resource,
string $message = '',
?\Throwable $previous = null,
) {
parent::__construct(
$message !== '' ? $message : \sprintf('permission denied: %s on %s', $permission, $resource),
['permission' => $permission, 'resource' => $resource],
null,
$previous,
);
}
#[\Override]
public function code(): ErrorCode
{
return ErrorCode::PermissionDenied;
}
}