• 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: ObjC error messages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ObjC error messages


  • Subject: Re: ObjC error messages
  • From: Malte Tancred <email@hidden>
  • Date: Mon, 18 Feb 2002 10:04:14 +0100

On thursday, february 14, 2002, at 04:10 , Marcel Weiher wrote:
I agree that some sort of logging should occurr if the exception
isn't handled.

DNU isn't an exception. It is a message that is sent by the runtime whose default implementation just happens to raise an exception, just like it also happens to log an error.

But I still argue that it should be handled the way
all other uncaught exceptions are handled, ie through the top level
execption handler.

DNU isn't an exception, it is a message sent by the runtime whose default implementation raises an exception. It would be a different issues if the runtime actually raised an exception. It doesn't.

Exceptions in Objective-C are an add-on that is not part of the basic runtime.

I begin to see what I was actually missing. :-)

However, it still feels a bit awkward. Please help me understand.

As far as I can see, the default mechanism in Obj-C (from the darwin source, ie no Foundation, no exceptions) for unrecognized messages is to log the error and then abort() the program.

In Foundation exceptions are introduced as a means of handling program inconsistencies at a higher level.

How come, from the point of view of the runtime, an unrecognized message isn't treated as such? Ie, it doesn't crash the program anymore, but instead transforms the error to a higher order exception, for callers to handle?

Exactly. Your object decides how to handle the message.
...
Exactly, if you decide to handle the message that is sent, then it won't even raise an exception. For example, Higher Order Messaging uses DNU-handling (forwardInvocation:, to be precise) in its implementation. So does NSProxy.
...
Yes, you can send different messages in your DNU handler, or none. You can also log messages or even raise an exception.

My 'problem' was that I was writing the class sending the message in the first place. As I could catch an exception and thereby handle the situation, I wondered why this logging occurred in the first place.

In my opinion this would be a 'fix' to an inconsistency in the
design of Apple's frameworks.

You are misunderstanding the design.

That might just be the case.

I suggest the inconsistency is corrected.

It isn't inconistent.

Ok, ok! :-)

It's not a big deal

Exactly. It is an even smaller deal (just the default implementation of a method that can be overriden)...

Sure, as long as you control the code. If it's not my code, like for example NSObject which is controlled by Apple, I'm not particularly fond of patching. It does work and I know how to do it, just don't like messing with others code. It might case strange problems.

It only looks like a workaround to a problem if you misunderstand how DNU works, for example by assuming that it is exception-based... ;-)

I must have misunderstood the whole concept of DNU. In fact, I don't know what DNU stands for at all. I've found two descriptions of the acronym that seems close enough: Do Not Use and Do Not Understand.

Care to enlighten me?

Cheerio,
Malte

--
Malte Tancred
Computer programmer, Oops AB, Sweden
mailto:email@hidden
http://www.oops.se/
_______________________________________________
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.

  • Follow-Ups:
    • Re: ObjC error messages
      • From: "Clark S. Cox III" <email@hidden>
    • Re: ObjC error messages
      • From: Sherm Pendley <email@hidden>
References: 
 >Re: ObjC error messages (From: Marcel Weiher <email@hidden>)

  • Prev by Date: Quicktime Transition Effects for Cocoa
  • Next by Date: Re: ObjC error messages
  • Previous by thread: Re: ObjC error messages
  • Next by thread: Re: ObjC error messages
  • Index(es):
    • Date
    • Thread