# Execute some logic after unsuccessful retries

**URL:** <https://community.temporal.io/t/execute-some-logic-after-unsuccessful-retries/3364>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [November 10, 2021, 2:41pm UTC](https://community.temporal.io/t/execute-some-logic-after-unsuccessful-retries/3364 "2021-11-10T14:41:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andriy\_Lewandowski](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/andriy_lewandowski/32/929_2.png) [@Andriy\_Lewandowski](https://community.temporal.io/u/Andriy_Lewandowski)\
**Post date:** [November 10, 2021, 2:41pm UTC](https://community.temporal.io/t/execute-some-logic-after-unsuccessful-retries/3364/1 "2021-11-10T14:41:40Z")

</div>

Hello,  
I am wondering whether there is some mechanism that allows executing custom logic as soon as all retries have been unsuccessful.

Thanks!

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [November 10, 2021, 3:01pm UTC](https://community.temporal.io/t/execute-some-logic-after-unsuccessful-retries/3364/2 "2021-11-10T15:01:34Z")

</div>

Yes, inside the workflow catch the ActivityFailure exception and perform the logic in the catch block:

```java
try {
  a.myActivity(..);
} catch (ActivityFailure e) {
 // custom logic
}

```
