@@ -78,6 +78,7 @@ export class HookFile extends ModuleBuilder {
7878 const PageParam = ( ) => this . runtime . type ( 'PageParam' ) ;
7979 const QueryError = ( ) => this . runtime . type ( 'QueryError' ) ;
8080 const assert = ( ) => this . runtime . fn ( 'assert' ) ;
81+ const isError = ( ) => this . runtime . fn ( 'isError' ) ;
8182
8283 const type = ( t : string ) => this . types . type ( t ) ;
8384
@@ -156,7 +157,7 @@ export class HookFile extends ModuleBuilder {
156157 yield ` const res = await ${ guard ( ) } (${ serviceName } .${ camel (
157158 method . name . value ,
158159 ) } (${ paramsCallsite } ));`;
159- yield ` if (res.errors.length ) {` ;
160+ yield ` if (${ isError ( ) } ( res) ) {` ;
160161 yield ` const handled: ${ QueryError ( ) } <${ type (
161162 'Error' ,
162163 ) } []> = { kind: 'handled', payload: res.errors };`;
@@ -207,7 +208,7 @@ export class HookFile extends ModuleBuilder {
207208 } ) } ,`;
208209 yield ` queryFn: async ({ pageParam }: ${ PageParam ( ) } ) => {` ;
209210 yield ` const res = await ${ guard ( ) } (${ methodExpression } (${ paramsCallsite } ));` ;
210- yield ` if (res.errors.length ) {` ;
211+ yield ` if (${ isError ( ) } ( res) ) {` ;
211212 yield ` const handled: ${ QueryError ( ) } <${ type (
212213 'Error' ,
213214 ) } []> = { kind: 'handled', payload: res.errors };`;
@@ -364,6 +365,7 @@ export class HookFile extends ModuleBuilder {
364365 const queryOptions = this . buildQueryOptions ( method ) ;
365366 const QueryError = ( ) => this . runtime . type ( 'QueryError' ) ;
366367 const assert = ( ) => this . runtime . fn ( 'assert' ) ;
368+ const isError = ( ) => this . runtime . fn ( 'isError' ) ;
367369 const type = ( t : string ) => this . types . type ( t ) ;
368370
369371 const serviceName = camel ( `${ this . int . name . value } _service` ) ;
@@ -392,7 +394,7 @@ export class HookFile extends ModuleBuilder {
392394 yield ` const res = await ${ guard ( ) } (${ serviceName } .${ camel (
393395 method . name . value ,
394396 ) } (${ paramsCallsite } ));`;
395- yield ` if (res.errors.length ) {` ;
397+ yield ` if (${ isError ( ) } ( res) ) {` ;
396398 yield ` const handled: ${ QueryError ( ) } <${ type (
397399 'Error' ,
398400 ) } []> = { kind: 'handled', payload: res.errors };`;
0 commit comments