diff --git a/collects/drracket/private/rep.rkt b/collects/drracket/private/rep.rkt index 289f80d965..c676f8c4ec 100644 --- a/collects/drracket/private/rep.rkt +++ b/collects/drracket/private/rep.rkt @@ -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) diff --git a/collects/scribblings/tools/language.scrbl b/collects/scribblings/tools/language.scrbl index 6d13a4a0fe..6c0024f7bc 100644 --- a/collects/scribblings/tools/language.scrbl +++ b/collects/scribblings/tools/language.scrbl @@ -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.