@@ -129,7 +129,7 @@ Declaring errors on an activity **changes its workflow-side call signature.**
129129So an errors-declaring activity is awaited as a result, not a plain value:
130130
131131``` typescript
132- import { tag } from " unthrown" ;
132+ import { P } from " unthrown" ;
133133
134134implementation : async (context , order ) => {
135135 const charged = await context .activities .chargeCard ({
@@ -141,16 +141,16 @@ implementation: async (context, order) => {
141141 ok : (payment ) => ({ status: " completed" as const , transactionId: payment .transactionId }),
142142 errCases : (matcher ) =>
143143 matcher
144- .with (tag (" @temporal-contract/ContractError" ), (error ) => {
144+ .with (P . tag (" @temporal-contract/ContractError" ), (error ) => {
145145 // error.errorName narrows; error.data is typed from the schema
146146 if (error .errorName === " CardDeclined" ) {
147147 return { status: " failed" as const , reason: error .data .reason };
148148 }
149149 return { status: " failed" as const , reason: error .errorName };
150150 })
151151 .with (
152- tag (" @temporal-contract/ActivityError" ),
153- tag (" @temporal-contract/ActivityCancelledError" ),
152+ P . tag (" @temporal-contract/ActivityError" ),
153+ P . tag (" @temporal-contract/ActivityCancelledError" ),
154154 (error ) => ({ status: " failed" as const , reason: error .message }),
155155 ),
156156 defect : (cause ) => ({
@@ -179,7 +179,7 @@ A workflow whose declared error caused the failure surfaces it as a
179179` WorkflowFailedError ` :
180180
181181``` typescript
182- import { tag } from " unthrown" ;
182+ import { P } from " unthrown" ;
183183
184184const result = await client .executeWorkflow (" processOrder" , {
185185 workflowId: " order-1" ,
@@ -190,7 +190,7 @@ result.match({
190190 ok : (output ) => console .log (" done:" , output ),
191191 errCases : (matcher ) =>
192192 matcher
193- .with (tag (" @temporal-contract/ContractError" ), (error ) => {
193+ .with (P . tag (" @temporal-contract/ContractError" ), (error ) => {
194194 switch (error .errorName ) {
195195 case " EmptyOrder" :
196196 return console .error (" no items on order" , error .data .orderId );
@@ -199,11 +199,11 @@ result.match({
199199 }
200200 })
201201 .with (
202- tag (" @temporal-contract/WorkflowNotFoundError" ),
203- tag (" @temporal-contract/WorkflowValidationError" ),
204- tag (" @temporal-contract/WorkflowAlreadyStartedError" ),
205- tag (" @temporal-contract/WorkflowFailedError" ),
206- tag (" @temporal-contract/WorkflowExecutionNotFoundError" ),
202+ P . tag (" @temporal-contract/WorkflowNotFoundError" ),
203+ P . tag (" @temporal-contract/WorkflowValidationError" ),
204+ P . tag (" @temporal-contract/WorkflowAlreadyStartedError" ),
205+ P . tag (" @temporal-contract/WorkflowFailedError" ),
206+ P . tag (" @temporal-contract/WorkflowExecutionNotFoundError" ),
207207 (error ) => console .error (" failed:" , error .message ),
208208 ),
209209 defect : (cause ) => console .error (" unexpected:" , cause ),
0 commit comments