def safe_read(path)
      path     = File.expand_path(path)
      name     = File.basename(path, '.*')
      contents = File.read(path)

      [name, contents]
    rescue Errno::EACCES
      raise Error::InsufficientFilePermissions.new(path: path)
    rescue Errno::ENOENT
      raise Error::FileNotFound.new(path: path)
    end
def safe_read(path)
      path     = File.expand_path(path)
      name     = File.basename(path, '.*')
      contents = File.read(path)

      [name, contents]
    rescue Errno::EACCES
      raise Error::InsufficientFilePermissions.new(path: path)
    rescue Errno::ENOENT
      raise Error::FileNotFound.new(path: path)
    end
"Safely" read the contents of a file on disk, catching any permission
 errors or not found errors and raising a nicer exception.

 @example Reading a file that does not exist
   safe_read('/non-existent/file') #=> Error::FileNotFound

 @example Reading a file with improper permissions
   safe_read('/bad-permissions') #=> Error::InsufficientFilePermissions

 @example Reading a regular file
   safe_read('my-file.txt') #=> ["my-file", "..."]

 @param [String] path
   the path to the file on disk

 @return [Array<String>]
   A array where the first value is the basename of the file and the
   second value is the literal contents from +File.read+.