use "replace" instead of "delete" for executable creation when

the file already exists and improve error handling

closes PR 13243
This commit is contained in:
Robby Findler 2012-11-22 15:07:34 -06:00
parent b4b7340fd9
commit 25e92e2cc2
2 changed files with 27 additions and 12 deletions

View File

@ -32,6 +32,7 @@
(import [prefix drracket:debug: drracket:debug^] (import [prefix drracket:debug: drracket:debug^]
[prefix drracket:tools: drracket:tools^] [prefix drracket:tools: drracket:tools^]
[prefix drracket:rep: drracket:rep^] [prefix drracket:rep: drracket:rep^]
[prefix drracket:init: drracket:init^]
[prefix drracket:help-desk: drracket:help-desk^]) [prefix drracket:help-desk: drracket:help-desk^])
(export drracket:language^) (export drracket:language^)
@ -689,6 +690,18 @@
[(launcher) create-module-based-launcher] [(launcher) create-module-based-launcher]
[(stand-alone) create-module-based-stand-alone-executable] [(stand-alone) create-module-based-stand-alone-executable]
[(distribution) create-module-based-distribution])]) [(distribution) create-module-based-distribution])])
(with-handlers ((exn:fail? (λ (msg)
(define sp (open-output-string))
(parameterize ([current-error-port sp])
(drracket:init:original-error-display-handler
(exn-message exn)
exn))
(message-box
(string-constant drscheme)
(string-append
(string-constant error-creating-executable)
"\n\n"
(get-output-string sp))))))
(create-executable (create-executable
program-filename program-filename
executable-filename executable-filename
@ -698,7 +711,7 @@
(if (boolean? mred-launcher) (if (boolean? mred-launcher)
mred-launcher mred-launcher
(eq? base 'mred)) (eq? base 'mred))
use-copy?))))) use-copy?))))))
;; create-executable-gui : (union #f (is-a?/c top-level-area-container<%>)) ;; create-executable-gui : (union #f (is-a?/c top-level-area-container<%>))
@ -851,7 +864,7 @@
;; ask-user-can-clobber-directory? : (is-a?/c top-level-window<%>) string -> boolean ;; ask-user-can-clobber-directory? : (is-a?/c top-level-window<%>) string -> boolean
(define (ask-user-can-clobber? filename) (define (ask-user-can-clobber? filename)
(eq? (message-box (string-constant drscheme) (eq? (message-box (string-constant drscheme)
(format (string-constant are-you-sure-delete?) filename) (format (string-constant are-you-sure-replace?) filename)
dlg dlg
'(yes-no) '(yes-no)
#:dialog-mixin frame:focus-table-mixin) #:dialog-mixin frame:focus-table-mixin)

View File

@ -120,6 +120,7 @@ please adhere to these guidelines:
(stop "Stop") (stop "Stop")
(&stop "&Stop") ;; for use in button and menu item labels, with short cut. (&stop "&Stop") ;; for use in button and menu item labels, with short cut.
(are-you-sure-delete? "Are you sure you want to delete ~a?") ;; ~a is a filename or directory name (are-you-sure-delete? "Are you sure you want to delete ~a?") ;; ~a is a filename or directory name
(are-you-sure-replace? "Are you sure you want to replace ~a?") ;; ~a is a filename or directory name
(ignore "Ignore") (ignore "Ignore")
(revert "Revert") (revert "Revert")
@ -995,6 +996,7 @@ please adhere to these guidelines:
(save-a-mzscheme-stand-alone-executable "Save a Racket Stand-alone Executable") (save-a-mzscheme-stand-alone-executable "Save a Racket Stand-alone Executable")
(save-a-mred-distribution "Save a GRacket Distribution") (save-a-mred-distribution "Save a GRacket Distribution")
(save-a-mzscheme-distribution "Save a Racket Distribution") (save-a-mzscheme-distribution "Save a Racket Distribution")
(error-creating-executable "Error creating executable:") ;; this is suffixed with an error message ala error-display-handler
(definitions-not-saved "The definitions window has not been saved. The executable will use the latest saved version of the definitions window. Continue?") (definitions-not-saved "The definitions window has not been saved. The executable will use the latest saved version of the definitions window. Continue?")
;; The "-explanatory-label" variants are the labels used for the radio buttons in ;; The "-explanatory-label" variants are the labels used for the radio buttons in