title: How to catch Ldap error and redirect to specified page when using Devise and devise_ldap_authenticatable
body: <p>I would like to show my login page with error message like "The system cannot log you on at this time. Please try again later" when there is ldap error during the login process.</p>
  
  <p>Currently, I have used the custom_failure.rb approach as described in
  <a href="https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated" rel="nofollow">https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated</a>
  and it is able to catch error like invalid username / password and I have redirected it to the login page
  showing the error messages as desired without problem.
  But this approach cannot catch the ldap errors.</p>
  
  <p>These ldap errors are shown as a very raw html page like the following:</p>
  
  <p>Errno::ETIMEDOUT in Devise::SessionsController#create</p>
  
  <p>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - connect(2)</p>
  
  <p>Rails.root: C:/extratxt/2.2.0/source/ruby/messaging
  Application Trace | Framework Trace | Full Trace</p>
  
  <p>Request</p>
  
  <p>Parameters:</p>
  
  <pre><code>{"utf8"=&gt;"✓",
   "user"=&gt;{"username"=&gt;"administrator",
   "password"=&gt;"[FILTERED]",
   "remember_me"=&gt;"0"},
   "commit"=&gt;"Sign in"}
  </code></pre>
  
  <p>Show session dump</p>
  
  <p>Show env dump
  Response</p>
  
  <p>Headers:</p>
  
  <p>None</p>
  
  <p>How can I prevent this and instead show my specified page (e.g. login page with my own error message) ? 
  Any idea ? Thanks</p>