Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Thu Aug 04, 2011 4:55 pm
Code: Select all
(define (test) (test1))
(define (my-error-handler)
(println "error # " (error-text (error-number)) " has occurred\n"))
(error-event 'my-error-handler)
(test)
OS = Windows7 x64
newlisp = v.10.3.2
newlisp window closed without messages, but I have Windows messge about error.
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Sat Aug 06, 2011 7:21 pm
I knew about 'error-number' and 'error-text', but why such "dramatical" :-) exit without newlisp error and with Windows error?
More precise variant, with the same exit:
Code: Select all
(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)
Has Linux the same problem?
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Sun Aug 07, 2011 1:55 am
In your last example:
Code: Select all
(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)
… the error handler itself produces an error and calls itself, causing an infinite loop, because 'test2' is not defined.
The following example:
Code: Select all
(define (my-error-handler)
(println (last (last-error)) " must exit")
(exit))
(error-event 'my-error-handler)
(test)
... runs well on all platforms:
Code: Select all
~> newlisp test
ERR: invalid function : (test) must exit
~> cat test
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Sun Aug 07, 2011 1:56 am
In your last example:
Code: Select all
(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)
… the error handler itself produces an error and calls itself in an infinite loop, because 'test2' is not defined.
The following example:
Code: Select all
(define (my-error-handler)
(println (last (last-error)) " must exit")
(exit))
(error-event 'my-error-handler)
(test)
... runs well on all platforms:
Code: Select all
~> newlisp test
ERR: invalid function : (test) must exit
~>
alex
Posts: 100 Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia
Post
by alex » Wed Aug 10, 2011 4:44 pm
I understand my mistake. Thanks you, Lutz.