From 2856c51520ed8e3f959ba982a3668872e3b2bb79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ju=CC=88rgen=20Walter?= Date: Fri, 12 Aug 2011 15:08:07 +0200 Subject: [PATCH] uses ParseError instead of Exception for invalid iCal file --- lib/ri_cal/parser.rb | 6 ++++-- spec/ri_cal/parser_spec.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ri_cal/parser.rb b/lib/ri_cal/parser.rb index 99d3dd10..fcb177c6 100644 --- a/lib/ri_cal/parser.rb +++ b/lib/ri_cal/parser.rb @@ -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: @@ -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: @@ -142,4 +144,4 @@ def parse_one(start, parent_component) #:nodoc: result end end -end \ No newline at end of file +end diff --git a/spec/ri_cal/parser_spec.rb b/spec/ri_cal/parser_spec.rb index dd8656d3..d135927b 100644 --- a/spec/ri_cal/parser_spec.rb +++ b/spec/ri_cal/parser_spec.rb @@ -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