• 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
Correct way to fail on load of document?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Correct way to fail on load of document?


  • Subject: Correct way to fail on load of document?
  • From: "Stephan R. Cleaves" <email@hidden>
  • Date: Tue, 29 Jan 2002 20:20:09 -0500

Hi,

I'm trying to gracefully handle the attempted load of an invalid file format in my NSDocument subclass. I implement loadDataRepresentation and I can easily determine when I receive an incorrectly formatted file, so I return false when I do. However, this results in the following...

ObjCJava WARNING:
jobjc_jvm_newObject(): constructor with signature (Ljava/lang/String;Ljava/lang/String;)V on class MyDocument failed (should morph the java exception)
2002-01-29 19:21:48.495 MyApp[1103] (null)

With the debugger I've tracked down that my loadDataRepresentation is in fact being called, by com.apple.cocoa.application.NSDocument.initWithContentsOfFile and that when I return false it is throwing a NullPointerException. The documentation certainly seems to indicate that this is the way to handle failure to load, but its far from graceful. What is the appropriate way to deal with an invalid file format?

thanks,
stephan


  • Prev by Date: hey, Cocoa, don't touch that cursor
  • Next by Date: use of NSUnarchiver
  • Previous by thread: Re: hey, Cocoa, don't touch that cursor
  • Next by thread: use of NSUnarchiver
  • Index(es):
    • Date
    • Thread