Re: catching uncaught exceptions
Re: catching uncaught exceptions
- Subject: Re: catching uncaught exceptions
- From: Shaun Wexler <email@hidden>
- Date: Mon, 9 Feb 2004 14:50:09 -0800
On Feb 9, 2004, at 10:51 AM, matt neuburg wrote:
>
I want to override Cocoa's policy of failing silently with a note to
>
the
>
Console when there is an exception, so I have created an NSApplication
>
subclass and implemented reportException: to call NSRunAlertPanel and
>
tell
>
the user.
Do you need to handle those exceptions, or just report them? If you
don't use stdErr for anything else, why don't you just capture its
output and put up your own console log panel? It could automatically
come to the front whenever a new message arrives. When the WWDC seed
of Panther came out, I wanted to play with NSOutputStream, so I wrote a
class for maintaining a log file, session log, and console windows in
an application. It's sanitary and lightweight. It runs a thread to
capture stdErr, blocking on read(). I used NSOutputStream to append to
a separate log file for the app, plus maintain session log data in
memory, and if you want to open windows and/or panels (shared, or
multiple!), it creates those for you, attached to a shared
NSTextStorage, which is updated as needed from the data. It's really
cool, and I'm completely happy with it. I'll attach the header, to
give you some ideas... Hey, this would be a great little (shareware?)
static lib for everyone to add to their projects, especially during
development. I really like the fact that I can have a console window
regardless of build/run/debug mode, and don't have to manually open
Xcode's debugger console window every time, plus then I can make the
damned run log window as small as it allows (and just what aren't we
allowed to disable it, hmm?!!). And it's really useful to have an
archived stdErr log, regardless of development cycle. I leave it
active in my beta app's code, so it can transmit the session log and/or
the archived log files back to me if I need debugging feedback from the
field. Personally, if a modal alert popped up every time an app caught
an exception, I'd trash that sucker, pronto. ;)
--
Shaun Wexler
MacFOH
http://www.macfoh.com
/
*=======================================================================
*/
//
// SKWConsole.h
// SKWBase
//
// Created by Shaun Wexler on Tue July 1 2003.
// Copyright (c) 2003 SKW Development. All rights reserved.
//
/
*=======================================================================
*/
#import "SKWBase.h"
@interface SKWConsole : SKWSingletonObject
{
NSMutableData *consoleSessionData;
NSTextStorage *sharedTextStorage;
NSDictionary *defaultAttributes;
NSOutputStream *logFileStream;
NSString *logFileName;
NSString *logFileDirectoryPath;
NSString *logFileSessionSeparator;
BOOL echoToStdOut;
volatile BOOL loggingStdErr;
}
+ (SKWConsole *)console;
+ (void)start;
+ (void)stop;
+ (NSPanel *)panel;
+ (NSWindow *)window;
+ (id)newConsoleWindowOfClass:(Class)class styleMask:(int)styleMask;
- (NSString *)logFileName;
- (NSString *)logFileDirectoryPath;
- (NSString *)logFileSessionSeparator;
- (void)setLogFileName:(NSString *)name;
- (void)setLogFileDirectoryPath:(NSString *)path;
- (void)setLogFileSessionSeparator:(NSString *)separator;
- (NSTextStorage *)textStorage;
- (NSData *)sessionData;
- (void)logStdErr:(BOOL)enableLogging echoToStdOut:(BOOL)echo;
- (void)flushAndClose;
- (BOOL)isLogging;
- (BOOL)echoesToStdOut;
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.