Perhaps, rather than focusing on how straightforwardly Active Record handles errors,
a more important thing to consider is how to prevent errors from occurring altogether. To do
that, we need to decipher each error Active Record can throw, what it means when it does throw
an error, and what really causes each to occur. Once we know the answers to these questions,
perhaps we can update our applications to avoid the exceptions altogether, or at least eliminate
them in as many cases as reasonably possible (rather than simply handling them).
Active Record Error Methods
By default, the Active Record Base class defines 17 Active Record error types. You can override
each of these error types as needed within your application, and each can be caught and dealt
with via the Ruby rescue clause. As we take a look at the details of each class, we??™ll attempt to
explain when each is raised, why it is raised, and what you can do to try to avoid the error in
the future.
CHAPTER 6 ?– ACTIVE RECORD TESTING AND DEBUGGING 144
ActiveRecordError
This is the generic Active Record error class and the superclass of all other errors that might be
raised by ActiveRecord.
Pages:
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334