File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
packages/trigger-sdk/src/v3
references/v3-catalog/src/trigger Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -264,14 +264,20 @@ export type TaskRunResult<TOutput = any> =
264
264
} ;
265
265
266
266
export class SubtaskUnwrapError extends Error {
267
- constructor ( taskId : string , subtaskError : unknown ) {
267
+ public readonly taskId : string ;
268
+ public readonly runId : string ;
269
+
270
+ constructor ( taskId : string , runId : string , subtaskError : unknown ) {
268
271
if ( subtaskError instanceof Error ) {
269
272
super ( `Error in ${ taskId } : ${ subtaskError . message } ` , { cause : subtaskError } ) ;
270
273
this . name = "SubtaskUnwrapError" ;
271
274
} else {
272
275
super ( `Error in ${ taskId } ` , { cause : subtaskError } ) ;
273
276
this . name = "SubtaskUnwrapError" ;
274
277
}
278
+
279
+ this . taskId = taskId ;
280
+ this . runId = runId ;
275
281
}
276
282
}
277
283
@@ -291,7 +297,7 @@ export class TaskRunPromise<T> extends Promise<TaskRunResult<T>> {
291
297
if ( result . ok ) {
292
298
return result . output ;
293
299
} else {
294
- throw new SubtaskUnwrapError ( this . taskId , result . error ) ;
300
+ throw new SubtaskUnwrapError ( this . taskId , result . id , result . error ) ;
295
301
}
296
302
} ) ;
297
303
}
Original file line number Diff line number Diff line change @@ -31,13 +31,17 @@ export const fetchPostTask = task({
31
31
export const anyPayloadTask = task ( {
32
32
id : "any-payload-task" ,
33
33
run : async ( payload : any ) => {
34
- const { url, method } = await tasks
35
- . triggerAndWait < typeof fetchPostTask > ( "fetch-post-task" , {
36
- url : "https://jsonplaceholder.typicode.comasdqdasd/posts/1" ,
37
- } )
38
- . unwrap ( ) ;
39
-
40
- console . log ( "Result from fetch-post-task 211111sss" , { output : { url, method } } ) ;
34
+ try {
35
+ const { url, method } = await tasks
36
+ . triggerAndWait < typeof fetchPostTask > ( "fetch-post-task" , {
37
+ url : "https://jsonplaceholder.typicode.comasdqdasd/posts/1" ,
38
+ } )
39
+ . unwrap ( ) ;
40
+
41
+ console . log ( "Result from fetch-post-task 211111sss" , { output : { url, method } } ) ;
42
+ } catch ( error ) {
43
+ console . error ( "Error in fetch-post-task" , { error } ) ;
44
+ }
41
45
42
46
return {
43
47
payload,
You can’t perform that action at this time.
0 commit comments