84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/wunderbar/script.rb', line 84
def evaluate(scope, locals, &block)
scope.content_type self.class.default_mime_type, charset: 'utf-8'
begin
Ruby2JS.convert(block ? block : data, ivars: locals, file: file).to_s
rescue Parser::SyntaxError => exception
scope.response.status = Wunderbar::ServerError.status
location = exception.diagnostic.location
"Syntax Error: line #{location.line}, column: #{location.column}" +
"\n#{exception}\n"
rescue Exception => exception
scope.response.status = Wunderbar::ServerError.status
output = "Internal Server Error: #{exception}\n"
exception.backtrace.each do |frame|
next if CALLERS_TO_IGNORE.any? {|re| frame =~ re}
output += " #{frame}\n"
end
output
end
end
|