You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wiebe de Jong <wi...@shaw.ca> on 2003/10/21 00:32:01 UTC
returning errors or exceptions
My struts application follows this pattern:
action <-> business delegate <-> session façade <-> dao
and there are certain database errors that I want to be displayed to the
user via ActionMessages.
Currently, the façade returns a record id (positive value) or error number
(negative value). The delegate passes the error value on to the action,
which creates the ActionMessage.
My co-workers are of the opinion that the façade should return record ids or
exceptions, and that the delegate should capture and translate these
exceptions into error values, which are then passed to the action.
Which way is better? Are there any other methods of doing this?
Wiebe de Jong
http://frontierj.blogspot.com <http://frontierj.blogspot.com/>
Re: returning errors or exceptions
Posted by "Craig R. McClanahan" <cr...@apache.org>.
Wiebe de Jong wrote:
>My struts application follows this pattern:
>
>
>
>action <-> business delegate <-> session façade <-> dao
>
>
>
>and there are certain database errors that I want to be displayed to the
>user via ActionMessages.
>
>
>
>Currently, the façade returns a record id (positive value) or error number
>(negative value). The delegate passes the error value on to the action,
>which creates the ActionMessage.
>
>
>
>My co-workers are of the opinion that the façade should return record ids or
>exceptions, and that the delegate should capture and translate these
>exceptions into error values, which are then passed to the action.
>
>
>
>Which way is better? Are there any other methods of doing this?
>
>
>
Depending on how much information you actually want to show the end
user, you might take an idea from the way that SQLException works, and
include the record identifier in the exception class itself. That way,
you wouldn't have to choose either-or, and the ultimate ActionMessage
you return could draw from both the error number and the text of the
exception message if it wanted to.
>
>
>Wiebe de Jong
>
>http://frontierj.blogspot.com <http://frontierj.blogspot.com/>
>
>
>
>
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org