*/ private $context; /** * @param string $failureCode STATEMENT_REFUSED, SETUP_FAILED, AMBIENT_TRANSACTION or POST_COMMIT_FAILED. * @param string $databaseError The database's own error text. * @param \Throwable|null $cause The exception that carried the error, when one did. * @param array $context Structured failure context. */ public function __construct(string $failureCode, string $databaseError, ?\Throwable $cause = null, array $context = array()) { parent::__construct($databaseError, 0, $cause); $this->failureCode = $failureCode; $this->context = $context; } /** @return string One of the class constants. */ public function getFailureCode(): string { return $this->failureCode; } /** * @return array */ public function getContext(): array { return $this->context; } /** @return string What a person reading the log or plugin screen should do about it. */ public function getHint(): string { $hints = array( self::STATEMENT_REFUSED => 'The database refused the write. A read-only, full or over-quota database pauses plugin writes and the plugin screen says so; any other refusal is a schema or statement fault.', self::SETUP_FAILED => 'The database transaction boundary could not be established; the write was not attempted.', self::AMBIENT_TRANSACTION => 'A caller-owned transaction is active; its owner retains commit and rollback control, and this write was not attempted.', self::POST_COMMIT_FAILED => 'The transaction committed, but completion failed. Do not replay the write; inspect the completion failure and reconcile derived state.', ); return $hints[$this->failureCode] ?? 'The database mutation failed; inspect the recorded failure context before retrying.'; } }