don't continue after an error when scribbling via the 'scribble html'

and 'scribble pdf' buttons in the drracket frame.

closes PR 12385
This commit is contained in:
Robby Findler 2011-11-21 16:54:41 -06:00
parent 94373ea9f9
commit 3da3e17c47
2 changed files with 25 additions and 22 deletions

View File

@ -906,12 +906,11 @@ all of the names in the tools library, for use defining keybindings
(parameter-doc
drracket:rep:after-expression
(parameter/c (or/c #f any/c))
(parameter/c (or/c #f (-> void?)))
top-level-expression
@{This parameter is used by @method[drracket:rep:text% evaluate-from-port].
When it is something other than @racket[#f], then DrRacket passes it to
@racket[eval] as the last thing that it does on the user's thread (before
cleaning up).})
When it is a thunk, then DrRacket invokes the thunk on the user's thread
as the last thing it does (before cleaning up).})

View File

@ -30,24 +30,28 @@
[fn
(parameterize ([drracket:rep:after-expression
(λ ()
(printf "scribble: loading xref\n")
(define xref ((dynamic-require 'setup/xref 'load-collections-xref)))
(printf "scribble: rendering\n")
(parameterize ([current-input-port (open-input-string "")])
((dynamic-require 'scribble/render 'render)
(list (eval 'doc))
(list fn)
#:render-mixin (dynamic-require (if html?
'scribble/html-render
'scribble/pdf-render)
'render-mixin)
#:xrefs (list xref)))
(cond
[html?
(send-url/file (path-replace-suffix fn suffix))]
[else
(parameterize ([current-input-port (open-input-string "")])
(system (format "open \"~a\"" (path->string (path-replace-suffix fn suffix)))))]))])
(define doc (with-handlers ((exn:fail? (λ (x) #f))) (eval 'doc)))
;; if (eval 'doc) goes wrong, then we assume that's because of
;; an earlier failure, so we just don't do anything.
(when doc
(printf "scribble: loading xref\n")
(define xref ((dynamic-require 'setup/xref 'load-collections-xref)))
(printf "scribble: rendering\n")
(parameterize ([current-input-port (open-input-string "")])
((dynamic-require 'scribble/render 'render)
(list doc)
(list fn)
#:render-mixin (dynamic-require (if html?
'scribble/html-render
'scribble/pdf-render)
'render-mixin)
#:xrefs (list xref)))
(cond
[html?
(send-url/file (path-replace-suffix fn suffix))]
[else
(parameterize ([current-input-port (open-input-string "")])
(system (format "open \"~a\"" (path->string (path-replace-suffix fn suffix)))))])))])
(send drs-frame execute-callback))]
[else
(message-box "Scribble" "Cannot render buffer without filename")]))))