[ActiveJob] Discard job not based on exception type

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[ActiveJob] Discard job not based on exception type

Duka
Hello,

I have seem Rails Guides about feature request and Im posting this idea/issue here, in case of someone is disposal to implement it, or if people enough think is a good idea maybe I can do, is a simple problem but seems to not have a ready-solution.

Basically, in the active job we have the `discard_on` method, which accepts a error type or a block(created to report the error somewhere else).

My issue is that I have 2 different errors that are the same type, but the error arguments and message are different, the error is ActiveResource::ClientError, I want basically discard this error when status is 400, and not discard when status is 403.

I did not found any solution for that, someone has any idea of how solve this? The block of discard_on did not seems to return an true/false, that would be the ideal solution, if return true then it is discarded, if returns false, not discard.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [ActiveJob] Discard job not based on exception type

George Claghorn-2
You can use rescue_from instead of discard_on:

On Thu, May 2, 2019 at 8:44 AM Duka <[hidden email]> wrote:
Hello,

I have seem Rails Guides about feature request and Im posting this idea/issue here, in case of someone is disposal to implement it, or if people enough think is a good idea maybe I can do, is a simple problem but seems to not have a ready-solution.

Basically, in the active job we have the `discard_on` method, which accepts a error type or a block(created to report the error somewhere else).

My issue is that I have 2 different errors that are the same type, but the error arguments and message are different, the error is ActiveResource::ClientError, I want basically discard this error when status is 400, and not discard when status is 403.

I did not found any solution for that, someone has any idea of how solve this? The block of discard_on did not seems to return an true/false, that would be the ideal solution, if return true then it is discarded, if returns false, not discard.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.