Skip to content

Commit bcc8b93

Browse files
committed
[py] better error handling when pipeline isn't found
Fixes: #1802 Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
1 parent e6b77b5 commit bcc8b93

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

python/feldera/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
pretty_errors.configure(
88
line_number_first=True,
99
)
10+
11+
pretty_errors.activate()

python/feldera/rest/errors.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,34 @@ def __init__(self, error: str, request: Response) -> None:
2525
self.message = None
2626
self.details = None
2727

28+
err_msg = ""
29+
2830
if request.text:
2931
try:
3032
json_data = json.loads(request.text)
33+
34+
self.error_code = json_data.get("error_code")
35+
if self.error_code:
36+
err_msg += f"\nError Code: {self.error_code}"
3137
self.message = json_data.get("message")
38+
if self.message:
39+
err_msg += f"\nMessage: {self.message}"
3240
self.details = json_data.get("details")
33-
self.error_code = json_data.get("error_code")
3441
except:
3542
self.message = request.text
3643

37-
def __str__(self) -> str:
38-
if self.error_code:
39-
return f"FelderaAPIError: {self.error}\n Error code: {self.error_code}\n Error message: {self.message}\n Details: {self.details}"
40-
else:
41-
return f"FelderaAPIError: {self.error}\n {self.message}"
44+
super().__init__(err_msg)
4245

4346

4447
class FelderaTimeoutError(FelderaError):
4548
"""Error when Feldera operation takes longer than expected"""
4649

47-
def __str__(self) -> str:
48-
return f"FelderaTimeoutError: {self.message}"
50+
def __init__(self, err: str) -> None:
51+
super().__init__(f"Timeout connecting to Feldera: {err}")
4952

5053

5154
class FelderaCommunicationError(FelderaError):
5255
"""Error when connection to Feldera"""
5356

54-
def __str__(self) -> str:
55-
return f"FelderaCommunicationError: {self.message}"
57+
def __init__(self, err: str) -> None:
58+
super().__init__(f"Cannot connect to Feldera API: {err}")

python/feldera/rest/feldera_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ def pause_pipeline(self, pipeline_name: str):
220220
if status == "Paused":
221221
break
222222
elif status == "Failed":
223-
# TODO: return a more detailed error message
224223
raise RuntimeError(f"Failed to pause pipeline")
225224

226225
logging.debug("still pausing %s, waiting for 100 more milliseconds", pipeline_name)
@@ -230,7 +229,7 @@ def shutdown_pipeline(self, pipeline_name: str):
230229
"""
231230
Shutdown a pipeline
232231
233-
:param pipeline_name: The name of the pipeline to shutdown
232+
:param pipeline_name: The name of the pipeline to shut down
234233
"""
235234

236235
self.http.post(

python/tests/test_pipeline_builder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ def test_sql_error(self):
284284
def test_kafka(self):
285285
import json
286286

287-
288287
in_ci = os.environ.get("IN_CI")
289288

290289
if in_ci == "1":

0 commit comments

Comments
 (0)