[racket] racket as cgi error with sqlite
On 03/30/2013 12:20 AM, prad wrote:
> Ryan Culpepper <ryanc at ccs.neu.edu> writes:
>
>> Without seeing an error message, I have no ideas. Are you sure that
>> lighttpd error logging is enabled?
>>
> it must be because i started to do some of this in php and i have error
> messages from 2013-03-24
>
>> If you still can't get the error
>> from lighttpd, maybe add a with-handlers around the failing db call
>> and write it to your own log file.
>>
> i have never done this - sounds really interesting.
> i would appreciate knowing where i can find info on how to do this.
Start with the Racket Guide, including the section on Input and Output
and the section on Exceptions and Control.
You probably want code that looks something like this:
;; path for log file, like "/tmp/racket-db-error"
(define error-log-file ....)
(with-handlers ([exn?
(lambda (e)
;; write the exception to the file
(with-output-to-file error-log-file
#:exists 'append
(lambda ()
(printf "the error is\n~s\n" e)))
;; re-raise the exception
(raise e))])
.... the db code that fails ....)
Ryan