-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathARCPException.php
More file actions
41 lines (36 loc) · 1.22 KB
/
ARCPException.php
File metadata and controls
41 lines (36 loc) · 1.22 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
<?php
declare(strict_types=1);
namespace Arcp\Errors;
/**
* Abstract base for every ARCP-protocol exception. Each concrete subclass
* binds to one {@see ErrorCode} and carries typed context (lease ids,
* deadlines, etc.) so callers don't have to fish through unstructured
* `details` arrays.
*
* RFC §18.1 defines the wire shape; this class is the in-process
* representation that round-trips through {@see Arcp\Json\EnvelopeSerializer}.
*/
abstract class ARCPException extends \RuntimeException
{
/**
* @param array<string, mixed> $details Optional structured context attached
* to the wire envelope's `details` field.
*/
public function __construct(
string $message,
public readonly array $details = [],
public readonly ?bool $retryable = null,
?\Throwable $previous = null,
) {
parent::__construct($message, 0, $previous);
}
abstract public function code(): ErrorCode;
/**
* Effective retryability — explicit override wins, otherwise the
* RFC §18.3 default for this code.
*/
public function isRetryable(): bool
{
return $this->retryable ?? $this->code()->defaultRetryable();
}
}