module Sprockets::Server
def javascript_exception_response(exception)
Returns a JavaScript response that re-throws a Ruby exception
def javascript_exception_response(exception) err = "#{exception.class.name}: #{exception.message}\n (in #{exception.backtrace[0]})" body = "throw Error(#{err.inspect})" [ 200, { "Content-Type" => "application/javascript", "Content-Length" => body.bytesize.to_s }, [ body ] ] end