Skip to content

Commit c46e757

Browse files
jacalataclaudebcantoni
authored
feat: expose JobFailedException and JobCancelledException at TSC top level (#1870)
* feat: expose JobFailedException and JobCancelledException at the top level Both were previously reachable only via `tableauserverclient.server.endpoint.exceptions`, which is an internal module path. Callers waiting on a background job with `server.jobs.wait_for_job()` need to catch these to distinguish a failed job from a cancelled one (JobCancelledException is a subclass of JobFailedException, so the order in an except-chain matters), and reaching into a `server.endpoint` sub-package to do so is a bad pattern to teach. Re-export them alongside the other exception types already exposed at the top level (FailedSignInError, MissingRequiredFieldError, NotSignedInError, ServerResponseError). Existing internal imports in tests and endpoints remain unchanged; this is purely additive. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Also expose FlowRunFailedException and FlowRunCancelledException at top level Same shape and same private-path problem as the Job exceptions this PR is already fixing. flow_runs.wait_for_flow_run() raises these; users need to catch them without importing from server.endpoint.exceptions. Add regression tests for both pairs so a future refactor of __init__.py can't silently break the public surface. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Brian Cantoni <bcantoni@salesforce.com>
1 parent 81fa0e3 commit c46e757

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎tableauserverclient/__init__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
RequestOptions,
6868
MissingRequiredFieldError,
6969
FailedSignInError,
70+
FlowRunCancelledException,
71+
FlowRunFailedException,
72+
JobCancelledException,
73+
JobFailedException,
7074
NotSignedInError,
7175
ServerResponseError,
7276
Filter,
@@ -98,13 +102,17 @@
98102
"FileuploadItem",
99103
"Filter",
100104
"FlowItem",
105+
"FlowRunCancelledException",
106+
"FlowRunFailedException",
101107
"FlowRunItem",
102108
"get_versions",
103109
"GroupItem",
104110
"GroupSetItem",
105111
"HourlyInterval",
106112
"ImageRequestOptions",
107113
"IntervalItem",
114+
"JobCancelledException",
115+
"JobFailedException",
108116
"JobItem",
109117
"JWTAuth",
110118
"LinkedTaskFlowRunItem",

‎tableauserverclient/server/__init__.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
from tableauserverclient.server.sort import Sort
1313
from tableauserverclient.server.server import Server
1414
from tableauserverclient.server.pager import Pager
15-
from tableauserverclient.server.endpoint.exceptions import FailedSignInError, NotSignedInError
15+
from tableauserverclient.server.endpoint.exceptions import (
16+
FailedSignInError,
17+
FlowRunCancelledException,
18+
FlowRunFailedException,
19+
JobCancelledException,
20+
JobFailedException,
21+
NotSignedInError,
22+
)
1623

1724
from tableauserverclient.server.endpoint import (
1825
Auth,
@@ -60,6 +67,10 @@
6067
"Server",
6168
"Pager",
6269
"FailedSignInError",
70+
"FlowRunCancelledException",
71+
"FlowRunFailedException",
72+
"JobCancelledException",
73+
"JobFailedException",
6374
"NotSignedInError",
6475
"Auth",
6576
"CustomViews",

‎test/test_import_surface.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import tableauserverclient as TSC
2+
from tableauserverclient.server.endpoint import exceptions
3+
4+
5+
def test_job_exceptions_at_top_level():
6+
assert TSC.JobFailedException is exceptions.JobFailedException
7+
assert TSC.JobCancelledException is exceptions.JobCancelledException
8+
assert "JobFailedException" in TSC.__all__
9+
assert "JobCancelledException" in TSC.__all__
10+
11+
12+
def test_flow_run_exceptions_at_top_level():
13+
assert TSC.FlowRunFailedException is exceptions.FlowRunFailedException
14+
assert TSC.FlowRunCancelledException is exceptions.FlowRunCancelledException
15+
assert "FlowRunFailedException" in TSC.__all__
16+
assert "FlowRunCancelledException" in TSC.__all__

0 commit comments

Comments
 (0)