3 ms·
Pretty sure this line: https://meowbark.dev/Better-error-handling#:~:text=return%20Result.fromThrowable(a%20/%20b%2C%20()%20%3D%3E%20new%20Error(%27Division%20b
by akoboldfrying 2y ago
Pretty sure this line: https://meowbark.dev/Better-error-handling#:~:text=return%20Result.fromThrowable(a%20/%20b%2C%20()%20%3D%3E%20new%20Error(%27Division%20by%20zero%27)) https://meowbark.dev/Better-error-handling#:~:text=return%20...
will immediately throw if b == 0, because
a / b
is evaluated immediately, so execution never makes it into fromThrowable(). Does it need to be
() => a / b
instead?
Similarly, withRetry()'s argument needs to have type "() => ResultAsync<T, ApiError>" -- at present, it is passed a result, and if that result is a RateLimit error, it will just return the same error again 1s later.