Skip to content

Commit 07922c4

Browse files
committed
error trapping
1 parent c6f76cd commit 07922c4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

regexplanet.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,22 @@ def get_or_post(path, opts={}, &block)
101101
end
102102
end
103103

104-
regex = Regexp.new(str_regex, options)
104+
begin
105+
regex = Regexp.new(str_regex, options)
106+
rescue Exception => e
107+
output << "\t<tr>\n"
108+
output << "\t\t<td>Exception</td>\n"
109+
output << "\t\t<td>"
110+
output << e.message
111+
output << "</td>\n"
112+
output << "\t</tr>\n"
113+
output << "</table>\n"
114+
return jsonp(
115+
:success => false,
116+
:message => "Regexp.new Exception: " + e.message,
117+
:html => output
118+
)
119+
end
105120
# when ruby 1.9
106121
#if Regexp.try_convert(str_regex)
107122
# output << "\t<tr>\n"

0 commit comments

Comments
 (0)