Navigation:  Programming Cookbook > Creating Console Applications >

Error Handling

Previous pageReturn to chapter overviewNext page

Unhandled exceptions that occur in a console application are handle slightly differently to those in a GUI application because the latter is event driven and the former is not. This is reflected by a different implementation of #unhandledException: in ConsoleSessionManager.

Untrapped errors are passed to ConsoleSessionManager>>logError:, which writes a description of the error to the stderr stream, and then, if non-resumable, the application is terminated.

Untrapped warnings are also passed to #logError:, but they are always resumable and so the application continues executing.

Untrapped notifications are printed to the trace device, which is the Win32 debug output device (i.e. OutputDebugString())

If the standard error handling does not meet your needs then you can override any of #onUnhandledError:, #onUnhandledWarning:, #onUnhandledNotification:, #logError: or (most likely) #unhandledException:.