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 (parameter-doc
drracket:rep:after-expression drracket:rep:after-expression
(parameter/c (or/c #f any/c)) (parameter/c (or/c #f (-> void?)))
top-level-expression top-level-expression
@{This parameter is used by @method[drracket:rep:text% evaluate-from-port]. @{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 When it is a thunk, then DrRacket invokes the thunk on the user's thread
@racket[eval] as the last thing that it does on the user's thread (before as the last thing it does (before cleaning up).})
cleaning up).})

View File

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