1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Mechanize Error: Mechanize::UnsupportedSchemeError


What Causes the Error?

The error Mechanize::UnsupportedSchemeError is raised when Mechanize tries to fetch a page using an unsupported protocol scheme, such as ftp or gopher. Mechanize supports only the file, http and https schemes.

This error can also manifest itself in the form of an ArgumentError with the message "unsupported scheme: #{uri.scheme}", where uri.scheme is the scheme of the URL you attempted to access.

How do I Fix The Error

Unfortunately, there's not much that can be done to fix this error. Mechanize can only access URLs beginning in http://, https:// and file://. All other schemes and protocols are unsupported. The best thing you can do is catch the error and try to handle it gracefully, or if you're really out of options, let the error fall through.

agent = Mechanize.new

  page = agent.get('gopher://gopher.example.com')
rescue Mechanize::UnsupportedSchemeError => e
  puts "Found link with unsupported scheme, trying another"
See More About
  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. The Mechanize 2.0 Handbook
  6. Mechanize Error: Mechanize::UnsupportedSchemeError

©2014 About.com. All rights reserved.