Add script specific error messages for response_variable (#95188)

This commit is contained in:
Allen Porter
2023-06-24 21:34:57 -07:00
committed by GitHub
parent ef2e55ecec
commit 528c206094
3 changed files with 81 additions and 4 deletions

View File

@@ -1753,6 +1753,17 @@ class ServiceRegistry:
"""
return service.lower() in self._services.get(domain.lower(), [])
def supports_response(self, domain: str, service: str) -> SupportsResponse:
"""Return whether or not the service supports response data.
This exists so that callers can return more helpful error messages given
the context. Will return NONE if the service does not exist as there is
other error handling when calling the service if it does not exist.
"""
if not (handler := self._services[domain][service]):
return SupportsResponse.NONE
return handler.supports_response
def register(
self,
domain: str,