MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / _get_instance_or_error

Method _get_instance_or_error

relay/server.py:508–522  ·  view source on GitHub ↗

Resolve instance; returns instance, None (not found), or error dict (ambiguous).

(
        self,
        request_id: str,
        instance_id: str | None,
    )

Source from the content-addressed store, hash-verified

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

Callers 2

_wait_for_instanceMethod · 0.95

Calls 3

from_codeMethod · 0.80
to_dictMethod · 0.45

Tested by

no test coverage detected