thanks, I'll have a look at it :) db On Fri, Jun 20, 2003 at 08:10:40PM +0900, Dmitry V. Sabanin wrote: > On Friday 20 June 2003 08:04, Daniel Bretoi wrote: > > Hi, > > > > Im trying to print all error information to the browser so I don't have > > to monitor the apache log every time I have a syntax error. > > > One day i wrote special addition to Exception class, so it outputs quite > pretty exception information to the browser window, it's attached. > When it's included u can just do this: > > begin > #code here > rescue Exception => e # not sure about this, i always had rescue => e here > e.backtrace_html if e.methods.include? 'backtrace_html' > end > > All backtracing code is made by 'in-place html' couse i wanted it to be > totally independent from any template engines and so on. > > Maybe it will be usefull to you. > > -- > sdmitry -=- Dmitry V. Sabanin > MuraveyLabs. > > class Exception def backtrace_html line_color = 'white' lineHead_color > = '#FDDFA0' error_color = 'red' special_color = 'blue' adminMail = > 'dmitry / iren.info' odd_color = 'F2E8B3' even_color = 'F5E693' errsect > = to_s.scan (/^([\w\s]*)[|]{3}/) if errsect.length > 0 errtext = > *to_s.scan(/[|]{3}(.*)$/) errtext = errtext.join('') else errtext = > to_s errsect = 'Unexpected' end print " > > Ruby Error Report (Version #{VERSION}, platform #{RUBY_PLATFORM}) > > #{errsect} error: > There was an error while perfoming your request: > #{CGI.escapeHTML(errtext)} > Exception type #{type.to_s} > > File Name Line Number Method Name " colorifier = 0 backtrace.each do > |line| fileName, lineNum, methodName = line.split(/:/) if > line.scan(/\d*:in/).length > 0 methodName = *methodName.scan(/`\w*'/) > methodName.gsub!(/[`']/,'') if methodName end if > colorifier.divmod(2)[1] == 0 row_color = odd_color else row_color = > even_color end print " > #{fileName} #{lineNum} #{methodName if defined? methodName} > " colorifier += 1 end print " > If you wish to help us, please e-mail our [1]administrator about this > error.. > This report was generated at #{Time.now}. > " end end > > References > > 1. mailto:/#{adminMail} -- Jun 22 Carl Hubbell born, 1903 Jun 22 Meryl Streep born in Summit, New Jersey, 1949 Jun 20 Victoria crowned, 1837 Jun 21 Berlin airlift begins, 1948 Jun 21 Sun rises over Heelstone at Stonehenge Jun 22 Civil rights workers disappear in Mississippi, 1964 Jun 20 Flag Day in Argentina Jun 20 West Virginia Day in West Virginia Jun 22 National Sovereignty Day in Haiti Jun 22 Corrective Movement in Yemen Democratic Republic Jun 22 Midsummer Eve in Finland, Sweden Jun 21 Columbia records announces the first mass production of LP's, 1948 Jun 22 Todd Rundgren is born in Upper Darby, Pennsylvania, 1948 Jun 21* Summer Solstice Jun 22* Parashat Balak Jun 22* Parashat Hukkat