I'm working on an extension of Module::Pluggable that builds in an Event/Trigger/Callback System. The event system allows all plugins to register for three slots of each event. I.e. calling the event "filter_html" will call it once for all plugins registered to handle it _before, once for _middle and once for _after. This seemed to give me some nice control and allow plugins to control exactly when they want to run. For instance if the plugin deals with cleaning up before the actual event then maybe it registers _before, while some might control the output and would therefore be after.

The Problem is that now sometimes a plugin might need to yell and say "stop processing other plugins at this level (before|middle|after)" and sometimes it might need to yell and say "hey we are dead in the water here so don't process any other plugins on this event." This is all fine and dandy so I set of with the idea to have magic return values. Immediatly this became a problem and had to be forgoten. So now i'm considering some alternatives. It would make sense if each plugin can edit the input and output, so that sounds like a context object, but i also want them to be able to abort which sounds like Exceptions.

The question then is....what do you think? I'm seeking some perl wisdom in this matter. I've never touched Exceptions and my experience with Context objects is that they are often a bit of extra code. Amy I missing something? Is this all a bad idea :) ? ... Thoughts, wisdom, guidance, stern yelling, and a swift paddle are all welcome.

Thanks in advance for any ideas.


___________
Eric Hodges

In reply to Exceptions vs Context Objects by eric256

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.