You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+131Lines changed: 131 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,6 +204,137 @@ async def create_workflow(
204
204
...
205
205
```
206
206
207
+
### Domain-level exceptions
208
+
209
+
1.**Define domain exceptions in the core layer** (`core/{domain}/types.py` or `core/{domain}/dtos.py`) — never raise `HTTPException` from services or DAOs.
210
+
2.**Catch domain exceptions at the API boundary** — in the router or via a decorator — and convert them to HTTP responses.
211
+
3.**Use a base exception per domain** so callers can catch broadly or narrowly.
212
+
4.**Include structured context** (not just a message string) so the router can build rich HTTP error responses.
213
+
214
+
**Example 1 — Folder exceptions (best example of the full pattern):**
215
+
216
+
Definition in `api/oss/src/core/folders/types.py`:
217
+
```python
218
+
classFolderNameInvalid(Exception):
219
+
def__init__(self, message: str="Folder name contains invalid characters."):
220
+
self.message = message
221
+
super().__init__(message)
222
+
223
+
classFolderPathConflict(Exception):
224
+
def__init__(self, message: str="A folder with this path already exists."):
225
+
self.message = message
226
+
super().__init__(message)
227
+
```
228
+
229
+
Raised in service `api/oss/src/core/folders/service.py`:
0 commit comments