Resolve instance; returns instance, None (not found), or error dict (ambiguous).
(
self,
request_id: str,
instance_id: str | None,
)
| 506 | ) |
| 507 | |
| 508 | def _get_instance_or_error( |
| 509 | self, |
| 510 | request_id: str, |
| 511 | instance_id: str | None, |
| 512 | ) -> UnityInstance | None | dict[str, Any]: |
| 513 | """Resolve instance; returns instance, None (not found), or error dict (ambiguous).""" |
| 514 | try: |
| 515 | instance = self.registry.get_instance_for_request(instance_id) |
| 516 | except AmbiguousInstanceError as e: |
| 517 | return ErrorMessage.from_code( |
| 518 | request_id, |
| 519 | ErrorCode.AMBIGUOUS_INSTANCE, |
| 520 | str(e), |
| 521 | ).to_dict() |
| 522 | return instance |
| 523 | |
| 524 | def _instance_needs_wait(self, instance: UnityInstance) -> bool: |
| 525 | return instance.status in (InstanceStatus.RELOADING, InstanceStatus.DISCONNECTED) or not instance.is_connected |
no test coverage detected