Mach-II/Mach-II-Framework — Issue #39: New filter idea - ExceptionDecisionFilter
Author: mpwoodward
Created: 2012-03-01 17:20:17+00:00
State: open
Labels: enhancement

(Moved from http://trac.mach-ii.com/machii/ticket/327)

Hi guys, just thinking about how I handle exceptions in my applications when I deploy them to different environments. When in development environments, all exceptions are displayed in a "developer" like page. When in production, certain exceptions are basically ignored giving users a nice error message (like missing events saying "Page does not exist or no longer exists) whereas other exceptions get an "Danger, Danger, Will Robinson...You broke our entire website" page.

Typically, that kind of setup looks like this:

```

```

I'm using a listener method to do the "filtering", but it really should have just been setup as a filter:

```

```

Now all the exception types are hard-coded in there, but it would be trivial to allow people to set them up via configure time parameters when defining the filter. Kind of like this:

```

```

The syntax is completely an "concept" at the moment using the environment enable like structs for environment groupes (we'd support specific environment names in addition to groups). The real question is do people like this idea and would people use it? We'd probably bake this into the skeleton.

Changed 3 years ago by Jorge Loyo

Hi Peter,

I like the idea. I am currently handling exceptions the way you explained in your post, with multiple event-handlers and a listener.

If this was implememented though, it would mean inserting a filter call for every event-handler in which you would like to handle exceptions, right?

Would it make sense, instead of a filter, having a plugin that could do this? And perhaps, allow a parameter that defines the events to skip the handling of exceptions?

This way is only located in one place and you don't have to go fetching for it everywhere? Just a thought...What do you think?

comment:2 Changed 3 years ago by peterfarrell

Hmm, I usually just use the exceptionEvent as a global exception handler and the filter I proposed above to do the event announcement as needed. I've never thrown exceptions from listener and just the above system to handle them (although you could, don't know the benefits) so I'm a bit perplexed about "inserting a filter call for every event-handler". The exception event-handler in the example above is global event-handler for un-handled exceptions so I'd probably only use the filter once in my application.

comment:3 Changed 3 years ago by peterfarrell

Cc jorgeloyo@gmail.com added
@Jorge, added your email as a CC address. FYI, I already responded to this ticket before you were added as a CC so you probably want to take a peek at the comment history.

comment:4 Changed 3 years ago by Jorge Loyo

you are right... I actually don't know what I was thinking when I responded since in fact, like you say, the exception handler is global and I handle my exceptions exactly as you originally posted on the ticket.

I do like the idea of the filter instead of a listener handling this.

comment:5 Changed 3 years ago by kurtwiersma

I like the idea of including a filter like this with the framework.

comment:6 Changed 3 years ago by brian pickens

I also like this idea. I am doing something similar.

comment:7 Changed 2 years ago by peterfarrell

Milestone changed from Mach-II 1.9.0 Un-Targeted to Uncategorized
Re-targeted for later consideration

comment:8 Changed 2 years ago by peterfarrell

Version changed from 1.9.0 - Framework to Uncategorized - Framework