errors = $errors ?? array(); $this->thrower = $thrower; $this->cached_id = $cached_id; parent::__construct( $message, $code, $previous ); } /** * Get a string representation of the exception object. * * @return string String representation of the exception object. */ public function __toString(): string { $cached_id_part = $this->cached_id ? ", id: {$this->cached_id}" : ''; return "CacheException: [{$this->thrower->get_object_type()}{$cached_id_part}]: {$this->message}"; } /** * Gets the array of error messages passed to the exception constructor. * * @return array Error messages passed to the exception constructor. */ public function get_errors(): array { return $this->errors; } /** * Gets the object that threw the exception as passed to the exception constructor. * * @return object The object that threw the exception. */ public function get_thrower(): object { return $this->thrower; } /** * Gets the id of the cached object as passed to the exception constructor. * * @return int|string|null The id of the cached object. */ public function get_cached_id() { return $this->cached_id; } }