Command Processor question

64 views
Skip to first unread message

Tomasz JASKULA

unread,
Oct 7, 2011, 4:57:16 AM10/7/11
to mvccontri...@googlegroups.com
Hi,

I'm using Command Processor from MvcContrib and I like it very much. There is only one thing I'm not sure about. When an exception occures in the command handler, there is no means to propagate it up higher layers which is quite understandable. What's your advice about handling exceptions in command handlers ? I would like to take componsatory actions on the UI when such an exception occurs.

Regards,

Thomas 

Daudi

unread,
Oct 7, 2011, 2:03:02 PM10/7/11
to mvccontrib-discuss
Hi,
I've also been quite happy with CommandProccessor. I'm using it in an
app that was based on the original CodeCampServer project.
In my case I'm using the full stack of tools with the CommandProcessor
ie.
- AutoMapper : for converting UI messages to Domain messages
- RulesEngine : for validating input from the UI using configurable
IValidationRule
- CommandHandler : mostly for saving objects to repository and
handling any business logic relating to the command.

You can easily wrap catch exceptions usig try..catch syntax in the
AutoMapper and CommandHandler stack.
The tricky ones are in the RulesEngine stack. What I've found is that
validation errors that are usually configured with
MessageDefinition<T> are returned in the Messages collection of
ExecutionResult

so, if you make a call like this from your controller:
var result = _rulesEngine.Process(message);

result.Messages should have something like "{0} is Missing or
Invalid." You'll be able to find the field that caused the error by
inspecting the IncorrectAttribute property of the said ErrorMessage
(its a LamdaExpression)

The CodeCampServer project uses some code in a custom ActionResult
called "CommandResult" that deals with deciphering the field from the
LambdaExpression.

I'm eager to hear what others have to say about this approach.

Regards,
Daudi

thoma...@hotmail.fr

unread,
Oct 9, 2011, 7:44:09 AM10/9/11
to mvccontri...@googlegroups.com
Hi Daudi,

Thank you for your response. I'm using quite the same stack for validation
with rules engine and command handling. My problem is about the command
handling. I can use try catch to prevent application to bug but as the
command handler returns an actual object definied in command handler
definition or null, there is no really a place to propagate the errors up to
the higer levels. I was interested how others do it ?

Thanks,

Thomas

-----Message d'origine-----
De : mvccontri...@googlegroups.com
[mailto:mvccontri...@googlegroups.com] De la part de Daudi
Envoyé : vendredi 7 octobre 2011 20:03
À : mvccontrib-discuss
Objet : [mvccontrib-discuss] Re: Command Processor question

Regards,
Daudi

--
Contact Jeffrey Palermo or Eric Hexter with specific questions about the
MvcContrib project. Or go to http://mvccontrib.org

To unsubscribe from this group, send email to
mvccontrib-disc...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mvccontrib-discuss?hl=en


Daudi

unread,
Oct 9, 2011, 5:15:56 PM10/9/11
to mvccontrib-discuss
Hi Thomas,
Have you tried ELMAH?
http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx
> MvcContrib project.  Or go tohttp://mvccontrib.org

Tomasz JASKULA

unread,
Oct 10, 2011, 4:29:04 AM10/10/11
to mvccontri...@googlegroups.com
Hi Daudi,

Yes, I know it, i just tried to find out if it could be solved at application level. For example to show a toast message to the user that something went wrong and that he could retry. Without handling it with a error 500 page.

Thomas

2011/10/9 Daudi <daud...@gmail.com>
Contact Jeffrey Palermo or Eric Hexter with specific questions about the MvcContrib project.  Or go to http://mvccontrib.org

Daudi

unread,
Oct 11, 2011, 11:13:46 AM10/11/11
to mvccontrib-discuss
I believe this is totally possible since Exceptions caught in the
CommandHandler stack are purely .NET. So it's totally up to you how
you want to handle them.
Check out Growl for toast-style notification. http://www.growlforwindows.com/gfw/developers.aspx


Rgs
Daudi

On Oct 10, 1:29 am, Tomasz JASKULA <thomasv1...@hotmail.fr> wrote:
> Hi Daudi,
>
> Yes, I know it, i just tried to find out if it could be solved at
> application level. For example to show a toast message to the user that
> something went wrong and that he could retry. Without handling it with a
> error 500 page.
>
> Thomas
>
> 2011/10/9 Daudi <daudi...@gmail.com>
>
>
>
>
>
>
>
> > Hi Thomas,
> > Have you tried ELMAH?
>
> >http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForA...
Reply all
Reply to author
Forward
0 new messages