Commit 167d2dba authored by aroben@apple.com's avatar aroben@apple.com
Browse files

Print exceptions from PrettyPatch to stdout

        This will make it much easier to debug problems with PrettyPatch,
        since we'll be able to see the exceptions in the browser.

        Reviewed by Sam Weinig.

        * PrettyPatch/prettify.rb: Added a --html-exceptions option, which
        will print exceptions to stdout as HTML.
        * attachment.cgi: Changed to pass --html-exceptions to prettify.rb.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34173 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 945ed0fc
2008-05-28 Adam Roben <aroben@apple.com>
Print exceptions from PrettyPatch to stdout
This will make it much easier to debug problems with PrettyPatch,
since we'll be able to see the exceptions in the browser.
Reviewed by Sam Weinig.
* PrettyPatch/prettify.rb: Added a --html-exceptions option, which
will print exceptions to stdout as HTML.
* attachment.cgi: Changed to pass --html-exceptions to prettify.rb.
2008-04-26 David Kilzer <ddkilzer@apple.com>
Removed temp files and added appropriate svn:ignore properties.
......
#!/usr/bin/ruby
require 'PrettyPatch'
require 'optparse'
require 'webrick/htmlutils'
BACKTRACE_SEPARATOR = "\n\tfrom "
options = { :html_exceptions => false }
OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [options] [patch-file]"
opts.separator ""
opts.on("--html-exceptions", "Print exceptions to stdout as HTML") { |h| options[:html_exceptions] = h }
end.parse!
patch_data = nil
if ARGV.length == 0 || ARGV[0] == '-' then
......@@ -9,4 +22,12 @@ else
File.open(ARGV[0]) { |file| patch_data = file.read }
end
puts PrettyPatch.prettify(patch_data)
begin
puts PrettyPatch.prettify(patch_data)
rescue => exception
raise unless options[:html_exceptions]
backtrace = exception.backtrace
backtrace[0] += ": " + exception + " (" + exception.class.to_s + ")"
print "<pre>\n", WEBrick::HTMLUtils::escape(backtrace.join(BACKTRACE_SEPARATOR)), "\n</pre>\n"
end
......@@ -733,7 +733,7 @@ sub prettyPatch
print $cgi->header(-type => 'text/html',
-expires => '+3M');
open2(\*OUT, \*IN, "/usr/bin/ruby", "-I", "PrettyPatch", "PrettyPatch/prettify.rb");
open2(\*OUT, \*IN, "/usr/bin/ruby", "-I", "PrettyPatch", "PrettyPatch/prettify.rb", "--html-exceptions");
print IN $thedata . "\n";
close(IN);
while (<OUT>) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment