# Getting failure details for a FAILED workflow via sdk

**URL:** https://community.temporal.io/t/getting-failure-details-for-a-failed-workflow-via-sdk/4953
**Category:** Community Support
**Tags:** java-sdk, advanced\_visibility, visibility
**Created:** [June 13, 2022, 2:43pm UTC](https://community.temporal.io/t/getting-failure-details-for-a-failed-workflow-via-sdk/4953 "2022-06-13T14:43:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ali\_akbar](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@ali\_akbar](https://community.temporal.io/u/ali_akbar)
#### Post date: [June 13, 2022, 2:43pm UTC](https://community.temporal.io/t/getting-failure-details-for-a-failed-workflow-via-sdk/4953/1 "2022-06-13T14:43:18Z")

</div>

Is there a means to get the failure details for a FAILED workflow with information like stack trace, exceptions, timeout details etc?

I can see a means to get that detail for `RUNNING` workflows which have failing retryable activities using `describeWorkflowExecutionResponse.getPendingActivitiesList().get(0).getLastFailure()` but the same method wouldn’t work for `FAILED` workflows as `PendingActivitiesList` would be empty.

I see that this information is available in the Temporal web UI (under Summary tab for a particular execution) but I was looking to see if it was possible to get the same information via the Java SDK.

---

<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: [June 13, 2022, 5:40pm UTC](https://community.temporal.io/t/getting-failure-details-for-a-failed-workflow-via-sdk/4953/3 "2022-06-13T17:40:56Z")

</div>

Hi @ali_akbar

for failed workflows you can attach to the failed workflow execution by using newWorkflowStub method for a known execution and then get the failure via getResult:

```auto
   MyWorkflow myFailedWorkflow =
        client.newWorkflowStub(
            MyWorkflow.class,
            "<workflow_id>",
            Optional.of("<workflow_run_id>"));
    WorkflowStub untyped = WorkflowStub.fromTyped(myFailedWorkflow);
    try {
      untyped.getResult(String.class);
    } catch (WorkflowFailedException e) {
      // ...
      if (e.getCause() instanceof ActivityFailure) {
        ActivityFailure activityFailure = (ActivityFailure) e.getCause();
        // ...
      }
      if (e.getCause() instanceof ChildWorkflowFailure) {
        ChildWorkflowFailure childWorkflowFailure = (ChildWorkflowFailure) e.getCause();
      }
      // ...
    }

```

---

<div class="post-metadata">

### Author: ![ali\_akbar](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@ali\_akbar](https://community.temporal.io/u/ali_akbar)
#### Post date: [June 14, 2022, 7:01am UTC](https://community.temporal.io/t/getting-failure-details-for-a-failed-workflow-via-sdk/4953/4 "2022-06-14T07:01:33Z")

</div>

Thanks for the quick response. This approach seems to solve my use case. 😃

For my solution, I already had the `WorkflowExecution` object so I just went ahead and created an untyped stub like so and the rest was pretty much the same:

```auto
WorkflowStub untypedStub = client.newUntypedWorkflowStub(workflowExecution, Optional.empty());

```
