You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Schumeyer <rs...@ieee.org> on 2006/11/01 15:28:19 UTC

ModuleException

Let me give this one more try:  I'm considering using the 
ModuleException class for exception handling.  It looks like a 
reasonably painless way to go.  Is there any reason *not* to use this 
method?  Or if anyone can point me to an example showing a better 
method, that would be great also.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ModuleException

Posted by Rick Schumeyer <rs...@ieee.org>.
umm...let me make something up real quick...one can obviously handle 
exceptions in non-struts Java apps.  I was thinking at the time you 
could do the same thing in struts, and simply not take advantage of any 
of the exception handling features of struts.

I didn't mean to suggest there is *one* traditional java way...perhaps a 
poor choice of words.

Christopher Schultz wrote:
> By the way, what is "the traditional Java way" in this case?
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ModuleException

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rick,

Rick Schumeyer wrote:
> I was hoping to learn about the pros/cons of various methods before
> picking one.

I prefer my technique because it does not require throwing another
exception. It's a tiny amount of time, but throwing an exception takes
more time than doing the work manually in the action. Also, I get to
direct Struts to my preferred error handler (ActionForward) instead of
using whatever has been configured globally as the exception handling page.

Perhaps it makes the Action code more verbose, but I am okay with that.

Just my .02

By the way, what is "the traditional Java way" in this case?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFSNyM9CaO5/Lv0PARAl5CAJ9zncxCrPn9iART66kFr8k3PSp1bQCbBu6f
Ns5fo+0kCXZSq3V4ujSdBBQ=
=/MyO
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ModuleException

Posted by Rick Schumeyer <rs...@ieee.org>.
Thanks for the reply.  It's not that I'm nervous about ModuleException, 
but rather that there are several ways to do it.  There is the 
traditional java way, ModuleException, your method of catching 
exceptions and forwarding to a global error page...and many others.  I 
was hoping to learn about the pros/cons of various methods before 
picking one.

Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Rick,
>
>   
>> Let me give this one more try:  I'm considering using the
>> ModuleException class for exception handling.  It looks like a
>> reasonably painless way to go.  Is there any reason *not* to use this
>> method?
>>     
>
> You mean exception, right?
>
> I recall your initial message and your concerns about requiring Struts.
> But, as you mentioned, you will be using this only in Action classes,
> which already (duh!) require Struts.
>
> Are you nervous about using these exceptions?
>
>   
>> Or if anyone can point me to an example showing a better
>> method, that would be great also.
>>     
>
> Typically, if I catch an exception from some service that I called (say,
> an application-specific exception), I'll go ahead and just insert the
> error messages directly like this:
>
> 	    ActionMessages errors = new ActionMessages();
>
> 	    errors.add(ActionMessages.GLOBAL_MESSAGE,
> 		       super.getActionMessage("error.whatever",
> 					      "MyBundle", request));
>
> 	    super.saveErrors(request, errors);
>
> 	    return mapping.findForward("error");
>
>
> Note that "super.getActionMessage" is a method that I wrote to get an
> error message from a specific bundle.
>
> My global "error" page prints out any error messages available in the
> request. No need to throw another exception.
>
> It really just comes down to what you want to do.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFFSL8y9CaO5/Lv0PARAjQjAKCYuBFRIoPyQwrdmm5Ox1tntZsl9gCgwGf2
> g6QF++OWAq6UiyNGzxXquvU=
> =IYly
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ModuleException

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rick,

> Let me give this one more try:  I'm considering using the
> ModuleException class for exception handling.  It looks like a
> reasonably painless way to go.  Is there any reason *not* to use this
> method?

You mean exception, right?

I recall your initial message and your concerns about requiring Struts.
But, as you mentioned, you will be using this only in Action classes,
which already (duh!) require Struts.

Are you nervous about using these exceptions?

> Or if anyone can point me to an example showing a better
> method, that would be great also.

Typically, if I catch an exception from some service that I called (say,
an application-specific exception), I'll go ahead and just insert the
error messages directly like this:

	    ActionMessages errors = new ActionMessages();

	    errors.add(ActionMessages.GLOBAL_MESSAGE,
		       super.getActionMessage("error.whatever",
					      "MyBundle", request));

	    super.saveErrors(request, errors);

	    return mapping.findForward("error");


Note that "super.getActionMessage" is a method that I wrote to get an
error message from a specific bundle.

My global "error" page prints out any error messages available in the
request. No need to throw another exception.

It really just comes down to what you want to do.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFSL8y9CaO5/Lv0PARAjQjAKCYuBFRIoPyQwrdmm5Ox1tntZsl9gCgwGf2
g6QF++OWAq6UiyNGzxXquvU=
=IYly
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org