Display a system-alert for callback errors in the UI; also for thread errors in deployed apps; fixes #92, fixes #95

db4
Slava Pestov 2011-10-03 00:24:13 -07:00
parent dabbe35bd9
commit c68e2308a8
4 changed files with 34 additions and 30 deletions

View File

@ -1,14 +1,6 @@
USING: compiler.units continuations kernel namespaces USING: namespaces tools.deploy.shaker ;
threads.private words vocabs tools.deploy.shaker ;
IN: debugger IN: debugger
: error. ( error -- ) original-error get die-with2 ; : error. ( error -- ) original-error get die-with2 ;
: print-error ( error -- ) error. ; : print-error ( error -- ) error. ;
"threads" vocab [
[
"error-in-thread" "threads" lookup
[ [ drop error. ] define ] [ f "combination" set-word-prop ] bi
] with-compilation-unit
] when

View File

@ -1,7 +1,11 @@
USING: namespaces tools.deploy.config fry sequences system kernel ui ui.gadgets.worlds ; USING: continuations namespaces sequences kernel ui
ui.gadgets.worlds ;
deploy-name get "Factor" or '[ [
_ " encountered an error." append "Error"
"The application encountered an error it cannot recover from and will now exit." "The application encountered an error it cannot recover from and will now exit."
system-alert die system-alert die
] ui-error-hook set-global ]
[ ui-error-hook set-global ]
[ callback-error-hook set-global ]
[ [ drop ] prepose thread-error-hook set-global ] tri

View File

@ -1,16 +1,20 @@
! Copyright (C) 2006, 2009 Slava Pestov. ! Copyright (C) 2006, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors debugger io kernel namespaces prettyprint USING: accessors continuations debugger io io.streams.string
ui.gadgets.panes ui.gadgets.worlds ui ; kernel namespaces prettyprint ui ui.gadgets.worlds ;
IN: ui.debugger IN: ui.debugger
: <error-pane> ( error -- pane ) : error-alert ( error -- )
<pane> [ [ print-error ] with-pane ] keep ; inline [ "Error" ] dip [ print-error ] with-string-writer
system-alert ;
: error-window ( error -- ) ! ( error -- )
<error-pane> "Error" open-window ; [ error-alert ] ui-error-hook set-global
[ error-window ] ui-error-hook set-global ! ( error -- )
[
ui-running? [ dup error-alert ] [ dup print-error ] if die
] callback-error-hook set-global
M: world-error error. M: world-error error.
"An error occurred while drawing the world " write "An error occurred while drawing the world " write

View File

@ -1,13 +1,14 @@
! Copyright (C) 2006, 2009 Slava Pestov. ! Copyright (C) 2006, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays hashtables io kernel math models USING: accessors arrays hashtables io kernel math models
colors.constants namespaces sequences words continuations debugger colors.constants namespaces sequences words continuations
prettyprint help editors fonts ui ui.commands ui.gestures ui.gadgets debugger prettyprint help editors fonts ui ui.commands
ui.pens.solid ui.gadgets.worlds ui.gadgets.packs ui.gadgets.buttons ui.debugger ui.gestures ui.gadgets ui.pens.solid
ui.gadgets.labels ui.gadgets.presentations ui.gadgets.viewports ui.gadgets.worlds ui.gadgets.packs ui.gadgets.buttons
ui.gadgets.tables ui.gadgets.tracks ui.gadgets.scrollers ui.gadgets.labels ui.gadgets.presentations ui.gadgets.panes
ui.gadgets.borders ui.gadgets.status-bar ui.tools.traceback ui.gadgets.viewports ui.gadgets.tables ui.gadgets.tracks
ui.tools.inspector ui.tools.browser ui.debugger ; ui.gadgets.scrollers ui.gadgets.borders ui.gadgets.status-bar
ui.tools.traceback ui.tools.inspector ui.tools.browser ;
IN: ui.tools.debugger IN: ui.tools.debugger
TUPLE: debugger < track error restarts restart-hook restart-list continuation ; TUPLE: debugger < track error restarts restart-hook restart-list continuation ;
@ -26,6 +27,9 @@ M: restart-renderer row-columns
t >>selection-required? t >>selection-required?
t >>single-click? ; inline t >>single-click? ; inline
: <error-pane> ( error -- pane )
<pane> [ [ print-error ] with-pane ] keep ; inline
: <error-display> ( debugger -- gadget ) : <error-display> ( debugger -- gadget )
[ <filled-pile> ] dip [ <filled-pile> ] dip
[ error>> <error-pane> add-gadget ] [ error>> <error-pane> add-gadget ]
@ -66,7 +70,7 @@ M: object error-in-debugger? drop f ;
[ [
dup error-in-debugger? dup error-in-debugger?
[ rethrow ] [ error-continuation get debugger-window ] if [ error-alert ] [ error-continuation get debugger-window ] if
] ui-error-hook set-global ] ui-error-hook set-global
debugger "gestures" f { debugger "gestures" f {