Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions packages/client-python/src/rocketride/mixins/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import mimetypes
from pathlib import Path
from typing import Dict, Any, List, Union, Tuple, Optional
from ..core import DAPClient
from ..core import DAPClient, PipeException
from ..types import PIPELINE_RESULT, UPLOAD_RESULT


Expand Down Expand Up @@ -174,7 +174,17 @@ async def open(self) -> 'DataMixin.DataPipe':
response = await self._client.request(request)

if self._client.did_fail(response):
raise RuntimeError(response.get('message', 'Your pipeline is not currently running.'))
msg = response.get('message') or 'Failed to open a data pipe.'
msg = (
f"{msg}\n\n"
"Common causes:\n"
"- Pipeline isn't running (wrong token or task terminated)\n"
"- Pipeline source is `chat` (use `client.chat()`), not `webhook`/`dropper`\n"
"- MIME type doesn't match the source lane (try `mimetype=\"text/plain\"`)\n"
)
response = dict(response)
response['message'] = msg
raise PipeException(response)
Comment thread
stepmikhaylov marked this conversation as resolved.
Comment thread
stepmikhaylov marked this conversation as resolved.

self._pipe_id = response.get('body', {}).get('pipe_id')
self._opened = True
Expand Down Expand Up @@ -224,7 +234,10 @@ async def write(self, buffer: bytes) -> None:
response = await self._client.request(request)

if self._client.did_fail(response):
raise RuntimeError(response.get('message', 'Failed to write to pipe'))
msg = response.get('message') or 'Failed to write to a data pipe.'
response = dict(response)
response['message'] = msg
raise PipeException(response)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

async def close(self) -> PIPELINE_RESULT:
"""
Expand Down Expand Up @@ -259,7 +272,10 @@ async def close(self) -> PIPELINE_RESULT:
response = await self._client.request(request)

if self._client.did_fail(response):
raise RuntimeError(response.get('message', 'Failed to close pipe'))
msg = response.get('message') or 'Failed to close a data pipe.'
response = dict(response)
response['message'] = msg
raise PipeException(response)

return response.get('body', {})

Expand Down
Loading