Skip to content

Commit 8c8c98e

Browse files
authored
udpate js + move note
Added JavaScript and Python examples for error handling in durable functions, including details on implementing IExceptionPropertiesProvider.
1 parent cf50411 commit 8c8c98e

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

articles/azure-functions/durable/durable-functions-error-handling.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,37 @@ public static async Task<List<string>> MyOrchestrator(
308308
```
309309
# [JavaScript (PM3)](#tab/javascript-v3)
310310

311+
```javascript
312+
df.app.orchestration("counterOrchestration", function* (context) {
313+
const entityId = new df.EntityId(counterEntityName, "myCounter");
311314

315+
try {
316+
const currentValue = yield context.df.callEntity(entityId, "get");
317+
if (currentValue < 10) {
318+
yield context.df.callEntity(entityId, "add", 1);
319+
}
320+
} catch (err) {
321+
context.log(`Entity call failed: ${err.message ?? err}`);
322+
}
323+
});
324+
```
312325
313326
# [JavaScript (PM4)](#tab/javascript-v4)
314327
328+
```javascript
329+
df.app.orchestration("counterOrchestration", function* (context) {
330+
const entityId = new df.EntityId(counterEntityName, "myCounter");
315331
332+
try {
333+
const currentValue = yield context.df.callEntity(entityId, "get");
334+
if (currentValue < 10) {
335+
yield context.df.callEntity(entityId, "add", 1);
336+
}
337+
} catch (err) {
338+
context.log(`Entity call failed: ${err.message ?? err}`);
339+
}
340+
});
341+
```
316342
317343
# [Python](#tab/python)
318344
@@ -753,6 +779,11 @@ When running Durable Task workflows in the .NET Isolated model, task failures ar
753779
754780
Starting with Microsoft.Azure.Functions.Worker.Extensions.DurableTask [v1.9.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.DurableTask/1.9.0), You can extend this behavior by implementing an IExceptionPropertiesProvider (defined in the Microsoft.DurableTask.Worker starting from [v1.16.1](https://www.nuget.org/packages/Microsoft.DurableTask.Worker/1.16.1)package). This provider defines which exception types and which of their properties should be included in the FailureDetails.Properties dictionary.
755781
782+
> [!NOTE]
783+
> - This feature is available in **.NET Isolated** only. Support for Java will be added in a future release.
784+
> - Make sure you're using **Microsoft.Azure.Functions.Worker.Extensions.DurableTask v1.9.0** or later.
785+
> - Make sure you're using **Microsoft.DurableTask.Worker v1.16.1** or later.
786+
756787
### Implement an Exception Properties Provider
757788
Implement a custom IExceptionPropertiesProvider to extract and return selected properties for the exceptions you care about. The returned dictionary will be serialized into the Properties field of FailureDetails when a matching exception type is thrown.
758789
@@ -817,11 +848,6 @@ When an exception occurs that matches your provider’s configuration, the orche
817848
}
818849
```
819850
820-
> [!NOTE]
821-
> - This feature is available in **.NET Isolated** only. Support for Java will be added in a future release.
822-
> - Make sure you're using **Microsoft.Azure.Functions.Worker.Extensions.DurableTask v1.9.0** or later.
823-
> - Make sure you're using **Microsoft.DurableTask.Worker v1.16.1** or later.
824-
825851
## Next steps
826852
827853
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)