make bugs like that in PR 11241 easier to diagnose / see by turning

the hang into a dialog.
This commit is contained in:
Robby Findler 2010-09-23 06:23:21 -05:00
parent 3f7343fdc7
commit 7dbb287601
2 changed files with 29 additions and 13 deletions

View File

@ -1678,18 +1678,28 @@ TODO
(send context disable-evaluation)
(reset-console)
(queue-user/wait
(λ () ; =User=, =No-Breaks=
(let ([lang (drracket:language-configuration:language-settings-language user-language-settings)])
(cond
;; this is for backwards compatibility; drracket used to
;; expect this method to be a thunk (but that was a bad decision)
[(object-method-arity-includes? lang 'first-opened 1)
(send lang first-opened
(drracket:language-configuration:language-settings-settings user-language-settings))]
[else
;; this is the backwards compatible case.
(send lang first-opened)]))))
(let ([exn-raised #f]
[lang (drracket:language-configuration:language-settings-language user-language-settings)])
(queue-user/wait
(λ () ; =User=, =No-Breaks=
(with-handlers ((exn:fail? (λ (x) (set! exn-raised x))))
(cond
;; this is for backwards compatibility; drracket used to
;; expect this method to be a thunk (but that was a bad decision)
[(object-method-arity-includes? lang 'first-opened 1)
(send lang first-opened
(drracket:language-configuration:language-settings-settings user-language-settings))]
[else
;; this is the backwards compatible case.
(send lang first-opened)]))))
(when exn-raised
(let ([sp (open-output-string)])
(parameterize ([current-error-port sp])
(drracket:init:original-error-display-handler (exn-message exn-raised) exn-raised))
(message-box (string-constant drscheme)
(format "Exception raised while running the first-opened method of the language ~s:\n~a"
(send lang get-language-position)
(get-output-string sp))))))
(insert-prompt)
(send context enable-evaluation)

View File

@ -638,7 +638,13 @@ main thread.
See also
@method[drracket:rep:text% initialize-console].
It does not have to accept both zero and one arguments; the zero argument
Calling this method should not raise an exception (or otherwise
try to escape). DrRacket is not in a position to signal the errors
as user errors when this is called. An error will cause DrRacket
to hang.
Contrary to the method contract space, this method
does not have to accept both zero and one arguments; the zero argument
version is for backwards compatibility and drracket tests the arity of the
method before invoking it.