Skip to content

Parsing error should not raise Exception but rather Error inherited from StandardError #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/ri_cal/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module RiCal
#- ©2009 Rick DeNatale
#- All rights reserved. Refer to the file README.txt for the license
#
class ParseError < StandardError; end

class Parser # :nodoc:
attr_reader :last_line_str #:nodoc:
def next_line #:nodoc:
Expand Down Expand Up @@ -87,7 +89,7 @@ def self.parse(io = StringIO.new("")) #:nodoc:
end

def invalid #:nodoc:
raise Exception.new("Invalid icalendar file")
raise ParseError.new("Invalid icalendar file")
end

def still_in(component, separated_line) #:nodoc:
Expand Down Expand Up @@ -142,4 +144,4 @@ def parse_one(start, parent_component) #:nodoc:
result
end
end
end
end
2 changes: 1 addition & 1 deletion spec/ri_cal/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def self.describe_named_property(entity_name, prop_text, prop_name, params, valu

it "should reject a file which doesn't start with BEGIN" do
parser = RiCal::Parser.new(StringIO.new("END:VCALENDAR"))
lambda {parser.parse}.should raise_error
lambda {parser.parse}.should raise_error(RiCal::ParseError)
end

describe "parsing an event" do
Expand Down