Sha256: d92b61afb41099b4a9ff70991341f27f8b0165ca2f7400a34aad2fa1501564f4
Contents?: true
Size: 852 Bytes
Versions: 1
Compression:
Stored size: 852 Bytes
Contents
# Responsible for creating a file and creating error messages which we can present back to the user if it failed class FileCreator class Error < StandardError; end attr_reader :error def create(file_name) File.new(file_name, 'w') rescue Errno::EACCES raise Error, "You do not have permission to write to that location (#{file_name})" rescue Errno::EISDIR raise Error, "File name is a directory (#{file_name})" rescue Errno::ENOTDIR raise Error, "File name refers to a directory which does not exist (#{file_name})" end # Errno errors handle error numbers returned by the operating system and translate them into rubyish errors # Therefore there may be slightly different errors on different operating systems, # but hopefully the ones we care about are generally applicable: http://ruby-doc.org/core/Errno.html end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pluginscan-0.9.0 | lib/file_creator.rb |