I've subclassed the devise RegistrationsController for creating new users and added some logic before calling the superclass's 'create' method. So, something like:
class RegistrationsController < Devise::RegistrationsController
def create
super end
I can tell if the superclass encountered an error by checking resource.errors.nil?. However, I want to distinguish between different errors. For instance, I want to do something different if the error is "Email has already been taken" versus some other error return.
I can parse the string, but that seems fragile to me. What if some future upgrade of ActiveRecord or Devise changes the string? What if the string get's localized in some way I don't expect?
Is anyone handling error processing in devise more gracefully than string parsing?