Commit a1a3db1
Anatolii
feat(exceptions): introduce Layer-1 structured exception hierarchy
Every public SDK exception now inherits from NullRunError and carries
four actionable fields (error_code, user_action, retryable, docs_url)
plus an optional chained cause. Users get a stable, grep-able error
code (NR-A001, NR-B002, NR-R001, ...) and a short imperative
next-step hint instead of a free-form message string.
New specialized classes (back-compat subclasses of existing
user-facing classes, so existing except clauses keep matching):
* NullRunConfigError — config/initialization failures
* NullRunAuthError — invalid/missing API key (subclass of
NullRunAuthenticationError)
* NullRunBackendError — gateway 5xx (subclass of
NullRunTransportError, retryable=True)
* NullRunBudgetError — budget exhausted (subclass of
NullRunBlockedException)
* NullRunToolBlockedError — tool blocked by policy (subclass of
NullRunBlockedException)
Existing except handlers keep working: every new class is a subclass
of an existing one, so e.g. 'except NullRunBlockedException' still
catches NullRunBudgetError and NullRunToolBlockedError.
Tests: tests/test_exception_hierarchy.py pins the hierarchy shape
(class roots), the structured fields on every public class, and the
five back-compat invariants (subclass matching for the user-facing
exception trees, BaseException isolation for WorkflowKilledInterrupt).
Verified locally: pytest 880 passed / 13 skipped, ruff check src/
clean, mypy src/ clean.1 parent 4610ba9 commit a1a3db1
6 files changed
Lines changed: 816 additions & 54 deletions
File tree
- src/nullrun
- breaker
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
101 | 108 | | |
102 | 109 | | |
103 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
104 | 119 | | |
105 | 120 | | |
106 | 121 | | |
| |||
146 | 161 | | |
147 | 162 | | |
148 | 163 | | |
| 164 | + | |
149 | 165 | | |
150 | 166 | | |
151 | 167 | | |
| |||
179 | 195 | | |
180 | 196 | | |
181 | 197 | | |
182 | | - | |
183 | 198 | | |
184 | 199 | | |
185 | 200 | | |
| |||
191 | 206 | | |
192 | 207 | | |
193 | 208 | | |
194 | | - | |
195 | 209 | | |
196 | 210 | | |
197 | 211 | | |
198 | 212 | | |
199 | 213 | | |
200 | 214 | | |
201 | | - | |
202 | 215 | | |
203 | 216 | | |
204 | 217 | | |
| |||
211 | 224 | | |
212 | 225 | | |
213 | 226 | | |
214 | | - | |
215 | 227 | | |
216 | 228 | | |
217 | | - | |
218 | 229 | | |
219 | 230 | | |
220 | 231 | | |
| |||
223 | 234 | | |
224 | 235 | | |
225 | 236 | | |
226 | | - | |
227 | 237 | | |
228 | 238 | | |
229 | 239 | | |
| |||
265 | 275 | | |
266 | 276 | | |
267 | 277 | | |
268 | | - | |
269 | 278 | | |
270 | 279 | | |
271 | 280 | | |
272 | 281 | | |
273 | 282 | | |
274 | | - | |
| 283 | + | |
275 | 284 | | |
276 | 285 | | |
277 | 286 | | |
| |||
0 commit comments