Monday, June 06, 2005

Cfbreak out of a component

Just on a lark, I tried using cfbreak to terminate a particular cfc from executing with the idea that the calling code would continue processing.

What do you know, it works. This can come in handy when you are debugging a lengthy cfc method. The cfc I'm working with doesn't return anything, so maybe it's not that handy if your calling code relies on a return value.

Interesting, none the less.

2 comments:

  1. Probably a better way to do that is to use an empty cfreturn tag (if your return type is void). There is nothing wrong with using an empty return tag, that is what you do in most languages (return;) to stop execution of a method or function.

    ReplyDelete
  2. Yep, that works better. Plus you can pump a dummy return object in there if you have to. I was just suprised that cfbreak worked at all outside of a loop.

    ReplyDelete