• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSError and user-cancel induced "errors"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSError and user-cancel induced "errors"


  • Subject: Re: NSError and user-cancel induced "errors"
  • From: "Timothy J. Wood" <email@hidden>
  • Date: Thu, 29 Sep 2005 15:30:01 -0700


On Sep 29, 2005, at 2:55 PM, Ali Ozer wrote:

Tim,
There is NSUserCancelledError which is for this purpose. It's specially treated by the NSError handling machinery in NSDocument/ NSApplication not to put up a panel.
Ali


Hrm... I totally missed that. It's 10.4 only, so we'll still need to do our own thing for 10.3 for a while longer.

The comments in NSResponder.h don't indicate if this has to be the immediate error or if it checks the underlying errors too. I will be fairly common to have a method that might fail for either a 'real' reason or a user-cancelled reason. In this case, another method calling it shouldn't have to check if the returned domain/code are the special cancelled combination (and then avoid stacking its error on top of the cancel).

In OmniFoundation I've taken the approach of putting a special key in the user info for user-cancel marking. Then, I have a category method:

/*" Returns YES if the receiver or any of its underlying errors has a user info key of OFUserCanceledActionErrorKey with a boolean value of YES. "*/
- (BOOL)causedByUserCanceling;
{
NSError *error = self;
while (error) {
NSDictionary *userInfo = [error userInfo];
if ([[userInfo valueForKey:OFUserCanceledActionErrorKey] boolValue])
return YES;
error = [userInfo valueForKey:NSUnderlyingErrorKey];
}
return NO;
}


  How does NSApplication/NSDocument handle this?

-tim


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSError and user-cancel induced "errors"
      • From: Ali Ozer <email@hidden>
References: 
 >NSError and user-cancel induced "errors" (From: "Timothy J. Wood" <email@hidden>)
 >Re: NSError and user-cancel induced "errors" (From: Ali Ozer <email@hidden>)

  • Prev by Date: Re: Background if Login Item launched
  • Next by Date: Re: NSEnumerator and the missing peek method
  • Previous by thread: Re: NSError and user-cancel induced "errors"
  • Next by thread: Re: NSError and user-cancel induced "errors"
  • Index(es):
    • Date
    • Thread