Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't hide Errno::ENOENT behind Citrus::Error

  • Loading branch information...
commit 0edd8e661bed22809d233849ae50f7eab81c7a7f 1 parent f760599
Michael Jackson authored
Showing with 7 additions and 9 deletions.
  1. +3 −0  CHANGES
  2. +4 −9 lib/citrus.rb
3  CHANGES
View
@@ -6,6 +6,9 @@
* Matches keep track of their offset in the original source (thanks
blambeau).
+ * Citrus.load no longer raises Citrus::LoadError for files that can't be found
+ or are not readable. Users must rescue Errno::ENOENT instead, for example.
+
= 2.4.1 / 2011-11-04
* Fixed a bug that prevented rule names from starting with "super".
13 lib/citrus.rb
View
@@ -73,9 +73,6 @@ def self.load(file, options={})
force = options.delete(:force)
if force || !cache[file]
- raise LoadError, "Cannot find file #{file}" unless ::File.file?(file)
- raise LoadError, "Cannot read file #{file}" unless ::File.readable?(file)
-
begin
cache[file] = eval(::File.read(file), options)
rescue SyntaxError => e
@@ -117,7 +114,10 @@ def self.require(file, options={})
end
# A base class for all Citrus errors.
- class Error < RuntimeError; end
+ class Error < StandardError; end
+
+ # Raised when Citrus.require can't find the file to load.
+ class LoadError < Error; end
# Raised when a parse fails.
class ParseError < Error
@@ -156,9 +156,6 @@ def detail
end
end
- # Raised when Citrus.load fails to load a file.
- class LoadError < Error; end
-
# Raised when Citrus::File.parse fails.
class SyntaxError < Error
# The +error+ given here is an instance of Citrus::ParseError.
@@ -399,8 +396,6 @@ def parse(source, options={})
# #root rule. Accepts the same +options+ as #parse.
def parse_file(path, options={})
path = Pathname.new(path.to_str) unless Pathname === path
- raise Error, "Cannot find file #{path}" unless path.exist?
- raise Error, "Cannot read file #{path}" unless path.readable?
parse(path, options)
end
Please sign in to comment.
Something went wrong with that request. Please try again.