The change to serialization mirrors the test just below it that also
uses a conditional for the assertion instead of a skip. The conditional
is necessary because memcached entries are not strings.
The class_serial test should not run on Ruby 3.2+ because class_serial
was replaced with Object Shapes. The class_serial value in RubyVM.stat
was removed in ruby/ruby@13bd617ea6
This is done by setting a special instance variable on the exception.
Another implementation could be to use an `ObjectSpace::WeakMap` as
a weak reference set, but I figured 3rd party error reporting libraries
may want to inspect wether the error was reported.
Fix: https://github.com/rails/rails/issues/43472
The reporter is held by the executor, but the `Rails` module provides a
nicer `Rails.error` shortcut.
For ease of use, two block based specialized methods are exposed.
`handle`, which swallow errors and forward them to the subscribers:
```ruby
Rails.error.handle do
1 + '1' # raises TypeError
end
1 + 1 # This will be executed
```
`record`, which forward the errors to the subscribes but let it
continue rewinding the call stack:
```ruby
Rails.error.record do
1 + '1' # raises TypeError
end
1 + 1 # This won't be executed.
```
For cases where the blocked based API isn't suitable, the lower level
`report` method can be used:
```ruby
Rails.error.report(error, handled: true / false)
```
These should allow external code to run blocks of user code to do
"work", at a similar unit size to a web request, without needing to get
intimate with ActionDipatch.