It would be useful to inspect the record in question every time an ActiveRecord exception is raised. This is currently possible with some (ActiveRecord::RecordNotSaved for instance), but not others. Any idea what the rationale for this selection is? I initially thought that you can query the exception for the record as long as it exists (or existed), but ActiveRecord::RecordNotSaved refutes that assumption, because you could be creating it for the first time.
The goal from such a proposal would be generic error collecting. For instance rescuing from all descendants of ActiveRecordError and passing the record id to Sentry, if it exists. But so far it won’t work with all of them
Not sure if it helps, but I was initially interested in the record associated with a StatementInvalid exception.