Hi,

ActiveJob exception handing can be performed using 'retry_on' and 
'discard_on'. To use the default exception handlers you can write:

*retry_on(CustomAppException)*

 

*discard_on(AnotherCustomAppException)*


To use custom exception handling with 'retry_on':

*retry_on(CustomAppException) do |job, exception|*
*  ExceptionNotifier.caught(exception)*
*end*


However, you cannot currently use custom exception handling with 
'discard_on' as the passed block isn't called. 

*discard_on(AnotherCustomAppException) do |job, exception|*
*  ExceptionNotifier.caught(exception) ### DOES NOT GET CALLED ###*
*end*


Instead you have to write:

*retry_on(AnotherCustomAppException, attempts: 1) do |job, exception|*
*  ExceptionNotifier.caught(exception)*
*end*


or 

*rescue_from(AnotherCustomAppException) do |exception|*
*  ExceptionNotifier.caught(exception)*
*end*


Would be nicer if the blocked passed to 'discard_on' was called and the 
following worked:

*discard_on(AnotherCustomAppException) do |job, exception|*
*  ExceptionNotifier.caught(exception)*
*end*


I've made this PR with the required changes: 
https://github.com/rails/rails/pull/30622

Thanks,
Aidan

-- 
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 rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to