fixed bug in exception handling for drawing; Closes PR 12044

(cherry picked from commit 562252f589)
This commit is contained in:
Matthias Felleisen 2011-07-15 11:47:42 -04:00 committed by Eli Barzilay
parent 29e8c44ba9
commit 14cd4ae26c
5 changed files with 45 additions and 7 deletions

View File

@ -258,10 +258,14 @@
(pdraw))
(queue-callback
(lambda ()
(with-handlers ([exn? (handler #t)])
(define H (handler #t))
(with-handlers ([exn? H])
; (define tag (object-name transform))
(define nw (transform (send world get) arg ...))
(define (d) (pdraw) (set-draw#!))
(define (d)
(with-handlers ((exn? H))
(pdraw))
(set-draw#!))
;; ---
;; [Listof (Box [d | void])]
(define w '())

View File

@ -2,11 +2,10 @@
(require 2htdp/universe)
(define s "")
(define x 0)
(define txt "expected to return a scene but this is a string")
(with-handlers ((exn? (lambda _ "success!")))
(with-handlers ((exn? (lambda (e) (unless (string=? (exn-message e) txt) (raise e)))))
(big-bang 0
(on-tick (lambda (w) (begin (set! x (+ x 1)) w)))
(to-draw (lambda (w) (set! s (number->string w))))))
(on-tick add1)
(to-draw (lambda (w) (error txt)))))

View File

@ -0,0 +1,16 @@
#lang racket
(require 2htdp/universe)
(require 2htdp/image)
(define (f x)
(cond
[(= x 0) (circle 10 'solid 'red)]
[(= x 1) (circle 20 'solid 'red)]
[else (error txt)]))
(define txt "all questions were #f")
(with-handlers ([exn? (lambda (e) (unless (string=? (exn-message e) txt) (raise e)))])
(big-bang 0 (on-tick add1) (to-draw f))
(error 'error-in-draw "test failed"))

View File

@ -0,0 +1,17 @@
#lang racket
(require 2htdp/universe)
(require 2htdp/image)
(define (f x) (circle 10 'solid 'red))
(define (g x)
(cond
[(= x 0) 1]
[else (error txt)]))
(define txt "all questions were #f")
(with-handlers ([exn? (lambda (e) (unless (string=? (exn-message e) txt) (raise e)))])
(big-bang 0 (on-tick g) (to-draw f))
(error 'error-in-tick "test failed"))

View File

@ -9,6 +9,8 @@ run() {
}
run bad-draw.rkt
run error-in-tick.rkt
run error-in-draw.rkt
run -t batch-io.rkt
run clause-once.rkt
run full-scene-visible.rkt