# Throwing NonRetryableErrors

**URL:** <https://community.temporal.io/t/throwing-nonretryableerrors/5707>\
**Category:** Community Support\
**Tags:** typescript-sdk\
**Created:** [August 18, 2022, 12:10am UTC](https://community.temporal.io/t/throwing-nonretryableerrors/5707 "2022-08-18T00:10:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rifruf](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/rifruf/32/2121_2.png) [@rifruf](https://community.temporal.io/u/rifruf)\
**Post date:** [August 18, 2022, 12:10am UTC](https://community.temporal.io/t/throwing-nonretryableerrors/5707/1 "2022-08-18T00:10:32Z")

</div>

So I currently have an activity that throws a non retryable error, but based on the behavior of my workflow, it seems like I’m not doing so correctly, specifically, it keeps retrying doSomething(), and never gets to handleFailure.

```auto
const activities = proxyActivities<testActivities>({
  startToCloseTimeout: '1h',
  heartbeatTimeout: '10m',
  taskQueue: 'default',
  retry: {
    nonRetryableErrorTypes: ['do_not_retry'],
  },
});

export const workflow = async () => {
    try {
        await activities.doSomething();
    } catch (e) {
        await activities.handleFailure(e);
    }
}

```

and then my activities are defined as

```auto
const testActivities {
    async doSomething() {
         throw new Error('do_not_retry');
    }
    async handleFailure(err) {
        console.log(err);
    }
}

```

---

<div class="post-metadata">

**Author:** ![loren](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/loren/32/5099_2.png) [@loren](https://community.temporal.io/u/loren)\
**Post date:** [August 18, 2022, 12:26am UTC](https://community.temporal.io/t/throwing-nonretryableerrors/5707/3 "2022-08-18T00:26:47Z")

</div>

`nonRetryableErrorTypes` takes a list of `ApplicationFailure` types. Replace

`throw new Error('do_not_retry');`

with

`throw new ApplicationFailure('message', 'do_not_retry')`

(type is second param)

> **[Class: ApplicationFailure | Temporal Node.js SDK API Reference](https://typescript.temporal.io/api/classes/common.applicationfailure/)**
>
> common.ApplicationFailure

---

<div class="post-metadata">

**Author:** ![rifruf](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/rifruf/32/2121_2.png) [@rifruf](https://community.temporal.io/u/rifruf)\
**Post date:** [August 18, 2022, 1:19am UTC](https://community.temporal.io/t/throwing-nonretryableerrors/5707/4 "2022-08-18T01:19:11Z")

</div>

Appreciate it. Something small btw, in the docs you referenced, it seems like create and fromError don’t work anymore (I couldn’t find the static modules in my installed temporal package) but are referenced in the docs? Also just to double check, but using/throwing Applicationfailure.nonRetryable will ensure that the activity isn’t retried, without me having to specify it in the proxyActivities retry config?

---

<div class="post-metadata">

**Author:** ![loren](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/loren/32/5099_2.png) [@loren](https://community.temporal.io/u/loren)\
**Post date:** [August 18, 2022, 2:00am UTC](https://community.temporal.io/t/throwing-nonretryableerrors/5707/5 "2022-08-18T02:00:15Z")

</div>

Sorry, it’s showing latest `main`—create and fromError will be in the next release.

> using/throwing Applicationfailure.nonRetryable will ensure that the activity isn’t retried, without me having to specify it in the proxyActivities retry config?

Yes
