File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
src/content/docs/workflows/build Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,24 @@ Get a specific Workflow instance by ID.
194194
195195 * ` id ` - the ID of the Workflow instance.
196196
197- Returns a ` WorkflowInstance ` .
197+ Returns a ` WorkflowInstance ` . Throws an exception if the instance ID does not exist.
198+
199+ ``` ts
200+ // Fetch an existing Workflow instance by ID:
201+ try {
202+ let instance = await env .MY_WORKFLOW .get (id )
203+ return Response .json ({
204+ id: instance .id ,
205+ details: await instance .status (),
206+ });
207+ } catch (e : any ) {
208+ // Handle errors
209+ // .get will throw an exception if the ID doesn't exist or is invalid.
210+ const msg = ` failed to get instance ${id }: ${e .message } `
211+ console .error (msg )
212+ return Response .json ({error: msg }, { status: 400 })
213+ }
214+ ```
198215
199216## WorkflowInstanceCreateOptions
200217
You can’t perform that action at this time.
0 commit comments