# Fail Workflow After Max Retries Help

**URL:** <https://community.temporal.io/t/fail-workflow-after-max-retries-help/6984>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [January 19, 2023, 8:37pm UTC](https://community.temporal.io/t/fail-workflow-after-max-retries-help/6984 "2023-01-19T20:37:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos.R](https://avatars.discourse-cdn.com/v4/letter/c/8491ac/32.png) [@Carlos.R](https://community.temporal.io/u/Carlos.R)\
**Post date:** [January 19, 2023, 8:37pm UTC](https://community.temporal.io/t/fail-workflow-after-max-retries-help/6984/1 "2023-01-19T20:37:11Z")

</div>

Hi Folks,

I just recently started using Temporal IO as a state management tool and I have a question regarding Workflow failures. I managed to set up my code where ActivityFailures are caught properly, but when my max attempts for a failed activity are reached, the workflow terminates normally.

Is there any way to throw a TemporalFailure or ApplicationFailure to ensure that the Temporal UI displays Failed instead of Completed for the workflow? I have been trying to figure this out but no luck. If you have any examples on how to do this that would be great. Thank you!

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [January 19, 2023, 10:33pm UTC](https://community.temporal.io/t/fail-workflow-after-max-retries-help/6984/2 "2023-01-19T22:33:04Z")

</div>

You can throw ApplicationFailure from your workflow code:

```auto
throw ApplicationFailure.newFailure(...);
throw ApplicationFailure.newFailureWithCause(...);

```

to fail execution.

---

<div class="post-metadata">

**Author:** ![Carlos.R](https://avatars.discourse-cdn.com/v4/letter/c/8491ac/32.png) [@Carlos.R](https://community.temporal.io/u/Carlos.R)\
**Post date:** [January 20, 2023, 7:09pm UTC](https://community.temporal.io/t/fail-workflow-after-max-retries-help/6984/3 "2023-01-20T19:09:13Z")

</div>

Great! That seems to have worked. Thanks for the help.
