Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Error messages and CGI

Reply
Thread Tools

Error messages and CGI

 
 
Henrik Ronellenfitsch
Guest
Posts: n/a
 
      02-08-2005
Hello,
is it possible to let ruby print error messages directly as text to the
cgi-output, like the way php prints it's error messages?
It's kind of impractical to always have to check the apache error log.

Thanks,
Henrik
 
Reply With Quote
 
 
 
 
Matt Armstrong
Guest
Posts: n/a
 
      02-08-2005
Henrik Ronellenfitsch <(E-Mail Removed)> writes:

> Hello,
> is it possible to let ruby print error messages directly as text to the
> cgi-output, like the way php prints it's error messages?
> It's kind of impractical to always have to check the apache error log.
>
> Thanks,
> Henrik


This approach will cause any exception in my main() function to be
printed out for the user to see. Syntax errors won't be caught, of
course, but even that can be handled by making the main .cgi script a
tiny wrapper with all the logic in a separate file that is loaded
within the begin...rescue...end. I stick my whole script in a timeout
block, since I've had odd problems cause a script to hang forever,
causing bad load on the HTTP server.

def exception_string(cgi, exception)
s1 = cgi.h1{"Exception:"} +
CGI::escapeHTML(exception.inspect) +
cgi.h1{"Backtrace:"}
s2 = ""
exception.backtrace.each { |line|
s2 = s2 + CGI::escapeHTML(line) + cgi.br
}
return s1 + s2
end

cgi = CGI::new('html4Tr')
begin
timeout(60 * 10) {
main(cgi)
}
rescue Exception => exception
cgi.out {
cgi.html {
cgi.head {
cgi.title { "#{TITLE}: Exception" }
} +
cgi.body {
exception_string(cgi, exception)
}
}
}
end

--
matt


 
Reply With Quote
 
 
 
 
Patrick May
Guest
Posts: n/a
 
      02-10-2005
Henrik,

On Tuesday, February 8, 2005, at 11:00 AM, Henrik Ronellenfitsch wrote:

> is it possible to let ruby print error messages directly as text to
> the cgi-output, like the way php prints it's error messages?
> It's kind of impractical to always have to check the apache error log.


To do this properly, you need to make the ruby interpreter web-aware.
This way you can catch SyntaxErrors. The development version of Narf
has such an interpreter. What platform are you working on?

In a month or so, Narf will have a major release. If you can't wait
and use subversion, you can check out narf at:

http://svn.narf-lib.org/svn/narf/trunk/

Cheers,

Patrick



 
Reply With Quote
 
Henrik Ronellenfitsch
Guest
Posts: n/a
 
      02-10-2005
Thank you both very much
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 9.3 How can I get better error messages from a CGI program? PerlFAQ Server Perl Misc 0 04-03-2011 04:00 AM
CGI (read multipart form): Accept-Charset encoding error (CGI::InvalidEncoding) Stefan Fischer Ruby 2 02-23-2010 08:17 AM
CGI Scripts: Catching and Displaying (Friendly) Error messages Sam Perl Misc 1 02-20-2007 10:03 PM
cgi and cgi-bin zippy Perl Misc 5 02-02-2005 01:46 AM
will all these messages cause a problem . I am a new subscriber and my computer is downloading 100,000 messages. Will this cause any kind of a problem with my ability to store other items?? Camille White Camille White Computer Support 9 11-08-2004 01:13 AM



Advertisments