@@ -177,7 +177,7 @@ export function generateOrmAgentsDocs(
177177 lines . push ( '' ) ;
178178 lines . push ( '- Prisma-like ORM client for a GraphQL API (TypeScript)' ) ;
179179 lines . push ( `- ${ tableCount } model${ tableCount !== 1 ? 's' : '' } ${ customOpCount > 0 ? `, ${ customOpCount } custom operation${ customOpCount !== 1 ? 's' : '' } ` : '' } ` ) ;
180- lines . push ( '- All methods return a query builder ; call `.execute()` to run' ) ;
180+ lines . push ( '- All methods return a QueryBuilder ; call `.execute()` to run, or `.unwrap()` to throw on error ' ) ;
181181 lines . push ( '' ) ;
182182
183183 lines . push ( '## Quick Start' ) ;
@@ -192,6 +192,30 @@ export function generateOrmAgentsDocs(
192192 lines . push ( '```' ) ;
193193 lines . push ( '' ) ;
194194
195+ lines . push ( '## Error Handling' ) ;
196+ lines . push ( '' ) ;
197+ lines . push ( '> **CRITICAL:** `.execute()` returns `{ ok, data, errors }` — it does **NOT** throw.' ) ;
198+ lines . push ( '> A bare `try/catch` around `.execute()` will silently swallow errors.' ) ;
199+ lines . push ( '' ) ;
200+ lines . push ( '```typescript' ) ;
201+ lines . push ( '// WRONG — errors are silently lost:' ) ;
202+ lines . push ( 'try { const r = await db.model.findMany({...}).execute(); } catch (e) { /* never runs */ }' ) ;
203+ lines . push ( '' ) ;
204+ lines . push ( '// RIGHT — .execute().unwrap() throws GraphQLRequestError on failure:' ) ;
205+ lines . push ( 'const data = await db.model.findMany({...}).execute().unwrap();' ) ;
206+ lines . push ( '' ) ;
207+ lines . push ( '// RIGHT — check .ok for control flow:' ) ;
208+ lines . push ( 'const result = await db.model.findMany({...}).execute();' ) ;
209+ lines . push ( 'if (!result.ok) { console.error(result.errors); return; }' ) ;
210+ lines . push ( 'return result.data;' ) ;
211+ lines . push ( '```' ) ;
212+ lines . push ( '' ) ;
213+ lines . push ( 'Available helpers (chain after `.execute()`):' ) ;
214+ lines . push ( '- `.execute().unwrap()` — throws on error, returns typed data' ) ;
215+ lines . push ( '- `.execute().unwrapOr(default)` — returns default value on error' ) ;
216+ lines . push ( '- `.execute().unwrapOrElse(fn)` — calls callback with errors on failure' ) ;
217+ lines . push ( '' ) ;
218+
195219 lines . push ( '## Resources' ) ;
196220 lines . push ( '' ) ;
197221 lines . push ( `- **Full API reference:** [README.md](./README.md) — model docs for all ${ tableCount } tables` ) ;
@@ -203,7 +227,7 @@ export function generateOrmAgentsDocs(
203227 lines . push ( '' ) ;
204228 lines . push ( '- Access models via `db.<ModelName>` (e.g. `db.User`)' ) ;
205229 lines . push ( '- CRUD methods: `findMany`, `findOne`, `create`, `update`, `delete`' ) ;
206- lines . push ( '- Always call `.execute()` to run the query ' ) ;
230+ lines . push ( '- Chain `.execute().unwrap() ` to run and throw on error, or `.execute()` alone for discriminated union result ' ) ;
207231 lines . push ( '- Custom operations via `db.query.<name>` or `db.mutation.<name>`' ) ;
208232 lines . push ( '' ) ;
209233
0 commit comments