From: Ryan Davis Date: 2011-12-27T18:10:54+09:00 Subject: Re: Kernel#exit raises an exception? On Dec 27, 2011, at 00:21 , Khat Harr wrote: > I'm catching the exception code that is returned from ruby_exec_node() > in order to print out errors. This is necessary in order to produce > error information because the implementation does not have console > window and allows end-users to add scripts. 'p' and 'print' are handled > by message boxes and if ruby_exec_node() returns an error code then the > implementation gathers $!.message and $!.backtrace and pops up a message > box describing the error. There needs to be a way for the end users to > be informed of errors created by their scripts. If I don't create a > handler for exit then the end-users won't be able to use 'exit' in their > scripts without producing an 'error' message box. How will catching NoMemoryError, SignalException, or SystemExit help you? As I said, catching Exception is almost always a mistake. It certainly is in this case. + Exception + NoMemoryError + ScriptError + LoadError + NotImplementedError + SyntaxError + SignalException + Interrupt + StandardError (default for rescue) + ArgumentError + IOError + EOFError + IndexError + LocalJumpError + NameError + NoMethodError + RangeError + FloatDomainError + RegexpError + RuntimeError (default for raise) + SecurityError + SystemCallError + Errno::* + SystemStackError + ThreadError + TypeError + ZeroDivisionError + SystemExit + fatal