Add ignore-errors to core

db4
Slava Pestov 2008-02-26 14:58:02 -06:00
parent aeef08cd51
commit da575528cf
4 changed files with 10 additions and 5 deletions

View File

@ -23,9 +23,10 @@ $nl
"Two words raise an error in the innermost error handler for the current dynamic extent:"
{ $subsection throw }
{ $subsection rethrow }
"Two words for establishing an error handler:"
"Words for establishing an error handler:"
{ $subsection cleanup }
{ $subsection recover }
{ $subsection ignore-errors }
"Unhandled errors are reported in the listener and can be debugged using various tools. See " { $link "debugger" } "."
{ $subsection "errors-restartable" }
{ $subsection "errors-post-mortem" } ;
@ -148,6 +149,10 @@ HELP: recover
{ $values { "try" quotation } { "recovery" "a quotation with stack effect " { $snippet "( error -- )" } } }
{ $description "Calls the " { $snippet "try" } " quotation. If an exception is thrown in the dynamic extent of the " { $snippet "try" } " quotation, restores the data stack and calls the " { $snippet "recovery" } " quotation to handle the error." } ;
HELP: ignore-errors
{ $values { "try" quotation } }
{ $description "Calls the quotation. If an exception is thrown in the dynamic extent of the quotation, restores the data stack and returns." } ;
HELP: rethrow
{ $values { "error" object } }
{ $description "Throws an error without saving the current continuation in the " { $link error-continuation } " global variable. This is done so that inspecting the error stacks sheds light on the original cause of the exception, rather than the point where it was rethrown." }

View File

@ -120,6 +120,9 @@ SYMBOL: thread-error-hook
: recover ( try recovery -- )
>r [ swap >c call c> drop ] curry r> ifcc ; inline
: ignore-errors ( quot -- )
[ drop ] recover ; inline
: cleanup ( try cleanup-always cleanup-error -- )
over >r compose [ dip rethrow ] curry
recover r> call ; inline

View File

@ -48,9 +48,6 @@ SYMBOL: this-test
: must-fail ( quot -- )
[ drop t ] must-fail-with ;
: ignore-errors ( quot -- )
[ drop ] recover ; inline
: (run-test) ( vocab -- )
dup vocab-source-loaded? [
vocab-tests

View File

@ -17,6 +17,6 @@ SYMBOL: vocab-monitor
[
"" resource-path t <monitor> vocab-monitor set-global
[ monitor-thread t ] "Vocabulary monitor" spawn-server drop
] [ drop ] recover ;
] ignore-errors ;
[ start-monitor-thread ] "vocabs.monitor" add-init-hook