*/ private $context; /** * Creates a push or commit failure with separate machine and human context. * * The machine-readable value comes first so a throw site names its recovery * class before giving instance-specific detail. It is retrieved with * get_error_code(), never Throwable::getCode(). * * @param string $error_code Stable machine-readable push or commit reason. * @param string $message Human-readable statement of the violated condition. * @param array $context Structured observations. Common keys * are operation, path_b64, conflict_path_b64, * expected_docroot_types, observed_docroot_identity, work_device, * docroot_device, work_type, blocking_push_session_id, and * observed_request_body_bytes. */ public function __construct(string $error_code, string $message, array $context = []) { parent::__construct($message); $this->error_code = $error_code; $this->context = $context; } /** * Returns the stable reason used to classify this push or commit failure. * * @return string Machine-readable error code suitable for a JSON `reason`. */ public function get_error_code(): string { return $this->error_code; } /** * Returns structured observations recorded by the throw site. * * The array contains only values supplied by push or commit throw sites. It * may be empty for simple classified failures, but when present it names * the exact observed condition that made the request non-recoverable or * recoverable. * * @return array Structured observations. Common keys are * operation, path_b64, conflict_path_b64, expected_docroot_types, * observed_docroot_identity, work_device, docroot_device, work_type, * blocking_push_session_id, and observed_request_body_bytes. */ public function get_context(): array { return $this->context; } }