Method: App47Logger#update_flash_messages

Defined in:
lib/app/models/concerns/app47_logger.rb

#update_flash_messages(exception, redirecting = false) ⇒ Object

Update the flash message based on the type of exception we get Currently we only handle mongoid errors, but there may be other common errors we can handle formatting for…



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/app/models/concerns/app47_logger.rb', line 127

def update_flash_messages(exception, redirecting = false)
  case exception
  when Mongoid::Errors::Validations
    if redirecting
      flash[:error] = exception.problem
      flash[:warning] = exception.summary
    else
      flash.now[:error] = exception.problem
      flash.now[:warning] = exception.summary
    end
  else
    if redirecting
      flash[:error] = exception.message
    else
      flash.now[:error] = exception.message
    end
  end
end