Handle response message, extracting result or raising error.
(self, response)
| 164 | return DirtyStreamIterator(self, app_path, action, args, kwargs) |
| 165 | |
| 166 | def _handle_response(self, response): |
| 167 | """Handle response message, extracting result or raising error.""" |
| 168 | msg_type = response.get("type") |
| 169 | |
| 170 | if msg_type == DirtyProtocol.MSG_TYPE_RESPONSE: |
| 171 | return response.get("result") |
| 172 | elif msg_type == DirtyProtocol.MSG_TYPE_ERROR: |
| 173 | error_info = response.get("error", {}) |
| 174 | error = DirtyError.from_dict(error_info) |
| 175 | raise error |
| 176 | else: |
| 177 | raise DirtyError(f"Unknown response type: {msg_type}") |
| 178 | |
| 179 | def _close_socket(self): |
| 180 | """Close the socket connection.""" |