Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add exception handling on wrong parsing

- TODO: Send exception error of the file that has problem parsing
  into a seperate file for user's debugging
  • Loading branch information...
commit a58150dc22d0ceb084fca77d8bc5f29f6aea60c7 1 parent 6a758e7
@davidchua authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 parsething.rb
View
8 parsething.rb
@@ -56,8 +56,10 @@ def parse
# @split = @people[/((Mr|Ms|Dr|[RAdm (NS)]|Mrs|[Assoc. Prof.])*\s(\w)+(.*)(\n|\w|[.])+)+/].split(/\n{2}/)
@people.gsub!('Assoc. Prof.', 'Associate Professor')
+ @people.gsub!('Asst. Prof.', 'Assistant Professor')
#debugger
- @split = @people[/((Mdm|Er|Prof|Mr|Ms|Dr|[RAdm (NS)]|Mrs|[Assoc. Prof.])*\s(\w)+(.*)(\n|\w|[.])+)+/].split('.')
+ @split = @people[/((Mdm|Er|Prof|Mr|Ms|Dr|[RAdm (NS)]|Mrs|[Asst. Prof.]|[Assoc. Prof.])*\s(\w)+(.*)(\n|\w|[.])+)+/].split('.')
+ puts @split
if !@split.nil?
@db = Sequel.connect("#$database_path")
@db.create_table? :attendance do
@@ -70,6 +72,7 @@ def parse
String :parliament
end
end
+ begin
@split.each do |t|
# is ______?
if t =~ /[_]+/
@@ -98,6 +101,9 @@ def parse
else
end
end
+ rescue
+ puts "Exception!"
+ end
# @people = @doc[/ABSENT:\n+(.*)-{10}/m, 1].split(/\n+/)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.