Re: NSError in NSDocument readFromURL
Re: NSError in NSDocument readFromURL
- Subject: Re: NSError in NSDocument readFromURL
- From: "I. Savant" <email@hidden>
- Date: Mon, 13 Jul 2009 09:52:56 -0400
If I set an NSError in the method readFromURL of my NSDocument, I
am not able to overwrite the NSLocalizedDescriptionKey.
Amazing how this works out sometimes - I *just* ran into this
yesterday for the first time.
Thanks for your answer, but is this behaviour somewhere documented?
I looked into NSDocumentControllers documentation but nothing about
such an error and what is actually evaluated for the standard alert
from the given NSError. How did you find out? Simply by try and error?
I've come across the documentation where it specifies the cocoa
domain and the "magic error code" to get the error ignored, but could
not figure out why my own error message was not displayed. I thought
it might be a you-know-what-version bug but the problem persisted on
Leopard and Tiger as well ...
I agree there doesn't *seem* to be an explanation of this in the
documentation. I read (and re-read) the Document-Based Applications
Overview as well as the NSDocument class reference. The overview
mentions the coco domain / error code trick for getting the message
ignored (and I saw that referenced somewhere else as well), but the
documentation for -[NSDocument initWithURL:ofType:error:] says only
this about the error pointer pointer:
"On return, If initialization is unsuccessful, a pointer to an error
object that encapsulates the reason the document could not be created."
It says nothing about special requirements for displaying it. I
think the best place is the overview, though, right along with the
Cocoa error domain bit. The NSDocumentController passage for -
makeDocumentWithContentsOfURL:ofType:error: says only:
"If not successful, the method returns nil after setting outError to
point to an NSError that encapsulates the reason why the document
could not be instantiated."
Operative word being "an" NSError. Funny enough, it ignores your
reason and never gives one itself. It just says it "could not be
opened." :-D
I'm tempted to call this an API bug, though, before I file
documentation bugs. I would expect it to work as the documentation
suggests - if I set an error, display that error, else why the hell
are you asking me to supply one?
Debate?
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden