Giter Club home page Giter Club logo

typescript-retry-decorator's Issues

Allow custom handling of last exception

It would be helpful to have the ability to handle what gets thrown in the end, in case there is a need to remap the error to something else. I did not see this functionality in the documentation, but perhaps it is already possible?

And thanks for making this library!

How does this plugin handle the last exception?

Hello, how does this plugin handle the last exception? For example, I set to retry 3 times. After 3 times, a 503 exception still occurs, and an email is sent. But after the plugin retries 3 times, I can't catch the exception, and I can't send the email. How to deal with this scenario?

TypeScript issue

Hi there! Seems like a nice and useful library but, unfortunately, I'm getting the following type error:
Screenshot 2023-07-23 at 12 04 50

I played with different TSconfig & package.json setups, tweaking this and that, but still can't even say if it's a deterministic issue or something specific to my IDE. Sometimes it appears and sometimes โ€“ not.
The above screenshot uses $ tsc --init > tsconfig.json version ๐Ÿค” Nothing fancy.

I realize it's hard to help me without a reproduceable code.
My hope is that this error might look familiar to the authors. Otherwise I'll try to find time to come up with a better demo.

support for retrying custom defined errors extended from Error class

Use Case

I need to pass custom defined error classes on the value field of the RetryOptions options object:

Code that reproduces error:

import { Retryable, BackOffPolicy} from "typescript-retry-decorator"

class CustomError extends Error {
  constructor(message?: string | undefined) {
    super(message)
    Object.setPrototypeOf(this, CustomError.prototype)
    this.name = 'CustomError'
  }
}

class Test {
   @Retryable({
    maxAttempts: 3,
    backOffPolicy: BackOffPolicy.FixedBackOffPolicy,
    backOff: 1000,
    value: [CustomError],
  })
    public async test() {
        throw new CustomError()
    }
}

Error

Type 'typeof CustomError' is not assignable to type 'ErrorConstructor'.
  Type 'typeof CustomError' provides no match for the signature '(message?: string | undefined): Error'

My build target is esnext

Could someone provide an example where a custom error class is passed to the value field of the RetryOptions object? The tests and examples do not include such case

Add an option to retry specific error classes

A common use case is to retry errors of certain types like FetchError or similar. doRetry does the job, but it is inconvenient for such a common use case.

Is it possible to add an option like errors: ErrorConstructor[] | ErrorConstructor to specify which error classes need to be retried?

Add option to include original exception message?

Would be fantastic to include the original exception message that caused the final retry

Currently we see

Error: Failed for 'foo' for 2 times.

Would like to see

Error: Failed for 'fo' for 2 times . Orginal Error : 'Null PTR Exception'

Add option to throw the original exception

I know the original error message is included when retries are exhausted, but it would be great to have the option to bubble up the original error instance itself stack trace and all. This would, of course, not be expected to be enabled by default as it would be a breaking change to existing functionality, but I imagine it could be enabled via the options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.